Bug 2128230

Summary: Dockerfile ARG command before FROM line breaks downstream container builds
Product: Red Hat OpenStack Reporter: Miguel Garcia <mgarciac>
Component: openstack-containersAssignee: Miguel Garcia <mgarciac>
Status: CLOSED NEXTRELEASE QA Contact: Arik Chernetsky <achernet>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 17.1 (Wallaby)CC: apevec, jpodivin, m.andre
Target Milestone: ---Keywords: AutomationBlocker, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-26 14:42:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miguel Garcia 2022-09-20 09:47:35 UTC
Dockerfile changes introduced in the latest 17.1 promotion from wallaby:
https://pkgs.devel.redhat.com/cgit/containers/openstack-base/commit/?h=rhos-17.1-rhel-9&id=fe85878cf7043211d66af5dd81df585bf30d5afc

+ARG ANSIBLE_RUNNER_IMAGE="quay.io/tripleoansible/ansible-runner:stream9"
+ARG TRIPLEO_ANSIBLE_REQ="/usr/share/openstack-tripleo-common-containers/container-images/kolla/tripleo-ansible-ee/requirements.yaml"
 FROM registry.access.redhat.com/ubi9:9.0.0

Cause downstream container builds to break because the use of ARG commands before the FROM command is not supported:
2022-09-19 09:32:37,695 - atomic_reactor.util - DEBUG - Step 1/50 : ARG ANSIBLE_RUNNER_IMAGE="quay.io/tripleoansible/ansible-runner:stream9"
2022-09-19 09:32:37,696 - atomic_reactor.util - ERROR - {'errorDetail': {'message': 'Please provide a source image with `from` prior to commit'}, 'error': 'Please provide a source image with `from` prior to commit'}

Another matter is that those variables shouldn't show up in all container images as they do now: they're supposed to be just for the new tripleo-ansible-ee container that hasn't been backported to wallaby just yet.

Related changes leading up to this:
https://review.opendev.org/c/openstack/tripleo-common/+/776674
https://review.opendev.org/c/openstack/tripleo-ci/+/850736

It appears that a quick solution would be to revert the above tripleo-ci change, like so:
https://review.opendev.org/c/openstack/tripleo-ci/+/857776

While a proper solution might be to:
1) Have tripleo-ansible put those ARGs after the FROM line. Change proposed: https://review.opendev.org/c/openstack/tripleo-ansible/+/858508

2) Have tripleo-common's tripleo-ansible-ee base image definition not rely on the old (broken) order of operations, as it does now:
https://opendev.org/openstack/tripleo-common/src/commit/04a69b47318e9c75f1d5c10089531a479517f465/container-images/tcib/tripleo-ansible-ee/tripleo-ansible-ee.yaml#L4

3) Fix tripleo-ci to have those extra_configs be added only to relevant images, instead of all of them as it does now:
https://review.opendev.org/c/openstack/tripleo-ci/+/850736