-
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
multiarch image pushing #84
multiarch image pushing #84
Conversation
The entire parameter for make was used as target as-is because without some outer shell, argument splitting and variable expansion is gone. The gcloud invocation then fits better into cloudbuild.yaml again, where it belongs (it's only needed when pushing to GCR).
/cc @vitt-bagal |
@pohly: GitHub didn't allow me to request PR reviews from the following users: vitt-bagal. Note that only kubernetes-csi members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
This removes code duplication: - the same Go environment is used for multiarch and for testing - BUILD_PLATFORMS determines what is getting build instead of hard-coding that in the make target - no separate Dockerfile.multiarch During the actual cloud build, BUILD_PLATFORMS is taken from the shared prow.sh. There's currently no support for overriding that per repo. We still need separate Dockerfiles for Linux and Windows because Windows has special requirements. In some lines, indention is changed to use tabs.
c78c975
to
cae4fbe
Compare
I need to take this back a bit: this is only true for local builds and Prow, but not for cloud build. There node-driver-registrar/cloudbuild.yaml Line 10 in cae4fbe
I think we should use the same approach as for Prow and install the desired Go version if it isn't available already. |
By moving the check before building binaries, users get the warning immediately when doing sequential builds.
This introduces .cloudbuild.sh as the main entry point for building cloud images, similar to the role that .prow.sh has for Prow testing. The script sets up the build environment (gcloud auth, installing Go, parsing some of the env variables) before invoking "make push-multiarch", which (as before) is usable also outside of a cloud build.
I've added that. |
/assign @msau42 |
cloudbuild.yaml
Outdated
- PULL_BASE_REF=$_PULL_BASE_REF | ||
- GIT_TAG=${_GIT_TAG} | ||
- PULL_BASE_REF=${_PULL_BASE_REF} | ||
- STAGING_PROJECT=${_STAGING_PROJECT} |
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.
Do we need a staging_project variable, or can we set REGISTRY directly?
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.
You are right, setting REGISTRY_NAME
directly is cleaner. I'm not even sure why we have _STAGING_PROJECT
under substitutions.
@vitt-bagal: do you remember where that came from? Isn't that always k8s-staging-csi
?
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.
@vitt-bagal: do you remember where that came from? Isn't that always k8s-staging-csi?
It came from this commit. I think this can be removed safely if we set REGISTRY_NAME
directly
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.
If we can move cloudbuild.yaml
into release-tools
and just symlink to it from the root directory of a project (similar to .travis.yml -> release-tools/travis.yml
), then it may make sense to have the substitution because different projects might have different staging projects.
Makefile
Outdated
dockerfile_linux=$$(if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi); \ | ||
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \ | ||
build_platforms='$(BUILD_PLATFORMS)'; \ | ||
if ! [ "$$build_platforms" ]; then build_platforms="linux amd64"; fi; \ |
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.
Can we set the default in L45?
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.
$(BUILD_PLATFORMS)
is expanded by make, so the usual shell mechanism (${var:-default}
) does not work.
I've combined the two lines into one with:
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi;
Makefile
Outdated
else \ | ||
: "release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists, skipping push"; \ | ||
: "release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists, skipping push"; \ |
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.
should this be silently ignored, or return an error?
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.
I haven't thought about this much. The whole if/else sequence here was copied originally from the corresponding "push" target and I just kept it. The original motivation for the check was that we directly push to the final destination, and those images should never be rebuilt because someone may already have pulled them. Here the situation is a bit different.
Do we expect that the cloud image build job will run more than once per tag? If no, then we can remove the "does the image exist" check because the image should never exist already. If yes, perhaps the build job was triggered intentionally again and the goal was to rebuild the image.
I'm leaning towards removing the check.
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.
I think we should never repush an existing tag (except for canary), even if there was some error. We would have to resolve that scenario by incrementing the tag.
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.
Okay, it's an error now.
@msau42: please take another look |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: msau42, pohly The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
The previous PR (#82) had an issue (make invocation) and several opens. With the changes in this PR,
push-multiarch
integrates better with the rest of the build rules by removing duplication:of hard-coding that in the make target
Dockerfile.multiarch
Which issue(s) this PR fixes:
Related-to kubernetes-csi/csi-release-tools#86
Special notes for your reviewer:
The result of
make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=pohly BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64"
can be found here: https://hub.docker.com/repository/docker/pohly/csi-node-driver-registrar [Update 2020-05-26: added arm64]Does this PR introduce a user-facing change?: