-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(image): merges manifests builder stages to one #773
fix(image): merges manifests builder stages to one #773
Conversation
We can combine two build stages to one, as there is no need to always build both images to only then decide from which one we want to copy manifests to the target image. Instead `manifests` stage will either copy local manifests or fetches using the script based on `FETCH_MANIFESTS` argument (previously known as `USE_LOCAL`). In addition it opens up `IMAGE_BUILD_FLAGS` variable to be overwritten when executing make targets instead of changing its value in the `Makefile` directly, as it was previously needed.
db658ef
to
b7735c3
Compare
Makefile
Outdated
# set to "true" to use local instead | ||
# see target "image-build" | ||
IMAGE_BUILD_FLAGS = --build-arg USE_LOCAL=false | ||
IMAGE_BUILD_FLAGS ?= --build-arg FETCH_MANIFESTS=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not make sense for the usage like in the README.md. Command line variables have priority in make anyway. Even over environment regardless of -e flag.
But may be having a separate variable to avoid passing --build-arg
can be a good idea, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not make sense for the usage like in the README.md. Command line variables have priority in make anyway. Even over environment regardless of -e flag.
That's right. Thanks for catching it. I think the source of confusion for me was not expecting to see both build stages (git clone and COPY
) executed in the original form of the docker file when I was expecting to see only the one based on the flag. That's now cleaned up in 0d3a574
But may be having a separate variable to avoid passing --build-arg can be a good idea, what do you think?
I am on the verge here. I have
alias image='make image -e IMAGE_BUILD_FLAGS="--build-arg FETCH_MANIFESTS=false" -e IMG=quay.io/maistra-dev/opendatahub-operator:$\(VERSION\) -e IMAGE_BUILDER=docker -e VERSION=dev-$(git branch --show-current)'
so I'm good.
Would it make it easier for you to have such a flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But may be having a separate variable to avoid passing --build-arg can be a good idea, what do you think?
I am on the verge here. I have
alias image='make image -e IMAGE_BUILD_FLAGS="--build-arg FETCH_MANIFESTS=false" -e IMG=quay.io/maistra-dev/opendatahub-operator:$\(VERSION\) -e IMAGE_BUILDER=docker -e VERSION=dev-$(git branch --show-current)'so I'm good.
Great! Just keep in mind that -e
is redundant here, it works differently for make than to podman-run.
Would it make it easier for you to have such a flag?
No actually, I haven't ever used that in practice :). So I personally would vote to avoid the change at all. Especially because it's unrelated to the purpose of the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartoszmajsak was thinking about avoiding go version setting in 4 places. One of the ideas was getting it from go.mod and instead of patching Dockerfile, pass it as the argument (similar to toolbox), but then your alias will be broken.
Dockerfiles/Dockerfile
Outdated
ARG GOLANG_VERSION=1.19 | ||
ARG USE_LOCAL=false | ||
ARG FETCH_MANIFESTS=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to leave it here (except as a matter of documentation) since according to the Dockerfile documentation ARG is valid till the next FROM (USE_LOCAL was expanded in the FROM line itself before)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, I cleared it up in 51d8c5d
It actually did not build both images (if I understand my build logs correctly) due to dependency tracking. But the change makes Dockerfile much cleaner. A question I have -- does it make sense to avoid that manifest stage and do it in the bulider? It used go-toolset image to make manifests before. |
@ykaliuta Ok I'm triple puzzled now, have a look at the build log below docker build
docker versionClient: Version: 20.10.17 API version: 1.41 Go version: go1.16.15 Git commit: aa7e414 Built: Fri Jul 8 23:32:01 2022 OS/Arch: linux/amd64 Context: default Experimental: true
|
Hah, interesting. Looks like podman is more clever. But I remember I read about dependencies in docker as well in the docs :) Makes more sense then. But what about squashing it one phase then? AFAIU it was splitted into two phases to make that condition on the image builder level. With the patch when it's in the script there is no sense for additional phase. Or I'm missing something? podman log```podman build --no-cache -f Dockerfiles/Dockerfile --build-arg USE_LOCAL=false -t quay.io/ykaliuta/opendatahub-operator:latest . [1/4] STEP 1/6: FROM registry.access.redhat.com/ubi8/go-toolset:1.19 AS builder_local_false [1/4] STEP 2/6: ARG OVERWRITE_MANIFESTS --> 0658cce527fa [1/4] STEP 3/6: USER root --> 6d2a0b9363d0 [1/4] STEP 4/6: WORKDIR /opt --> 3bd13acfa0fb [1/4] STEP 5/6: COPY get_all_manifests.sh get_all_manifests.sh --> fc074ef2b318 [1/4] STEP 6/6: RUN ./get_all_manifests.sh ${OVERWRITE_MANIFESTS} Cloning repo kserve: opendatahub-io:kserve:release-v0.11.0:config:kserve Cloning into './.kserve'... Cloning repo odh-dashboard: opendatahub-io:odh-dashboard:incubation:manifests:dashboard Cloning into './.odh-dashboard'... Cloning repo odh-notebook-controller: opendatahub-io:kubeflow:v1.7-branch:components/odh-notebook-controller/config:odh-notebook-controller/odh-notebook-controller Cloning into './.kubeflow'... Cloning repo notebooks: opendatahub-io:notebooks:main:manifests:notebooks Cloning into './.notebooks'... Cloning repo odh-model-controller: opendatahub-io:odh-model-controller:release-0.11.0:config:odh-model-controller Cloning into './.odh-model-controller'... Cloning repo ray: opendatahub-io:kuberay:master:ray-operator/config:ray Cloning into './.kuberay'... Cloning repo kf-notebook-controller: opendatahub-io:kubeflow:v1.7-branch:components/notebook-controller/config:odh-notebook-controller/kf-notebook-controller Cloning into './.kubeflow'... Cloning repo data-science-pipelines-operator: opendatahub-io:data-science-pipelines-operator:main:config:data-science-pipelines-operator Cloning into './.data-science-pipelines-operator'... Cloning repo trustyai: trustyai-explainability:trustyai-service-operator:release/1.10.2:config:trustyai-service-operator Cloning into './.trustyai-service-operator'... Cloning repo model-mesh: opendatahub-io:modelmesh-serving:release-0.11.0:config:model-mesh Cloning into './.modelmesh-serving'... Cloning repo codeflare: opendatahub-io:codeflare-operator:main:config:codeflare Cloning into './.codeflare-operator'... --> a0196c56ddc5 [3/4] STEP 1/13: FROM a0196c56ddc53a2f62783f1a40a0ecc47ec0c05055fb7f7dbe1afa161d9ede1d AS builder [3/4] STEP 2/13: USER root --> 92530b5fda6a [3/4] STEP 3/13: WORKDIR /workspace --> 262e23812a42 [3/4] STEP 4/13: COPY go.mod go.mod --> e39a33962a8b [3/4] STEP 5/13: COPY go.sum go.sum --> d145cda8323c [3/4] STEP 6/13: RUN go mod download --> 4a2bee6f7ac5 [3/4] STEP 7/13: COPY apis/ apis/ --> 432be0644019 [3/4] STEP 8/13: COPY components/ components/ --> 8d409afb27fd [3/4] STEP 9/13: COPY controllers/ controllers/ --> b046471d1ddf [3/4] STEP 10/13: COPY main.go main.go --> 35582a002821 [3/4] STEP 11/13: COPY pkg/ pkg/ --> 2c2841d130be [3/4] STEP 12/13: COPY infrastructure/ infrastructure/ --> 405d2af8cba9 [3/4] STEP 13/13: RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go --> b4b01e4fb965 [4/4] STEP 1/7: FROM registry.access.redhat.com/ubi8/ubi-minimal:latest [4/4] STEP 2/7: WORKDIR / --> 5a1ddd47a55a [4/4] STEP 3/7: COPY --from=builder /workspace/manager . --> 4873e93cdc67 [4/4] STEP 4/7: COPY --chown=1001:0 --from=builder /opt/odh-manifests /opt/manifests --> 4fc738ad01f0 [4/4] STEP 5/7: RUN chown -R 1001:0 /opt/manifests && chmod -R a+r /opt/manifests --> 984a23fbba03 [4/4] STEP 6/7: USER 1001 --> ff88d059ae68 [4/4] STEP 7/7: ENTRYPOINT ["/manager"] [4/4] COMMIT quay.io/ykaliuta/opendatahub-operator:latest --> e154b0975db4 Successfully tagged quay.io/ykaliuta/opendatahub-operator:latest e154b0975db48709bbcb7aa5b5f3f8da65fddbf404beb7bde816a6c6b08e2328 ``` |
I assumed podman is clever, but I'm on a very outdated fedora on my main workstation and podman ain't happy about it :)
Let's not start this squash discussion again! Just kidding :D Personally, I like such separation, but if we significantly trim on execution time and image sizes, then I'm happy to do it. WDYT @zdtsw? |
/test opendatahub-operator-e2e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zdtsw The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
/test opendatahub-operator-e2e |
New changes are detected. LGTM label has been removed. |
/retest |
/test opendatahub-operator-e2e |
@bartoszmajsak: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
The PR is still in my github list of assignment. It was approved, looks good to me as well, but was not merged due to failing tests. |
@ykaliuta Unfortunately, I don't have the bandwidth to dive into a year-old PR at the very moment. That said, I’d like to know if this approach is still worth it. If it does I can squeeze in some time in the coming days. |
We can combine two build stages into one, as there is no need to always build both images (not done by podman) to only then decide from which one we want to copy manifests to the target image. Instead manifests stage will either copy local manifests or fetches using the script based on USE_LOCAL argument. Move USE_LOCAL and OVERWIRTE_MANIFESTS args under FROM since args have scope of the FROM they are declared in. It requires opt/manifests directory to exist, but since it's a part of git repo, it's fine. Original patch from: Bartosz Majsak <[email protected]> [1] [1] opendatahub-io#773 Signed-off-by: Yauheni Kaliuta <[email protected]>
Well, you are the customer of that, with podman nobody noticed :) Ok, I fetched the main change into #1381 avoiding interface changes. |
Pull request was closed
We can combine two build stages into one, as there is no need to always build both images (not done by podman) to only then decide from which one we want to copy manifests to the target image. Instead manifests stage will either copy local manifests or fetches using the script based on USE_LOCAL argument. Move USE_LOCAL and OVERWIRTE_MANIFESTS args under FROM since args have scope of the FROM they are declared in. It requires opt/manifests directory to exist, but since it's a part of git repo, it's fine. Original patch from: Bartosz Majsak <[email protected]> [1] [1] opendatahub-io#773 Signed-off-by: Yauheni Kaliuta <[email protected]>
Description
We can combine two build stages into one, as there is no need to always build both images to only then decide from which one we want to copy manifests to the target image. Instead
manifests
stage will either copy local manifests or fetches using the script based onFETCH_MANIFESTS
argument (previously known asUSE_LOCAL
).In addition, it opens up
IMAGE_BUILD_FLAGS
variable to be overwritten when executing make targets instead of changing its value in theMakefile
directly, as it was previously needed.How Has This Been Tested?
Merge criteria: