Skip to content

Use buildah instead of docker, support multi-arch builds#115

Merged
kubevirt-bot merged 5 commits intokubevirt:mainfrom
maya-r:buildah-and-arm64
Aug 3, 2022
Merged

Use buildah instead of docker, support multi-arch builds#115
kubevirt-bot merged 5 commits intokubevirt:mainfrom
maya-r:buildah-and-arm64

Conversation

@maya-r
Copy link
Copy Markdown
Contributor

@maya-r maya-r commented Jul 6, 2022

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
hostpath-provisioner part of #98, we also need to change make push in project-infra to build arm64 binaries.

Special notes for your reviewer:

Release note:

Use buildah and podman, enable building multi-arch manifests

maya-r added 3 commits July 6, 2022 00:49
This passes them to all subprocesses, but they can still be overridden
due to the ?= construct.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
Avoid failure when the binary is built with Fedora 36 and thus
requires newer glibc symbols than the container.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
Now we can run:
make clean && \
GOARCH=arm64 make manifest && GOARCH=amd64 make manifest && \
make manifest-push

And spit out a manifest for both arm64 and amd64, in the same image.

Caveats:
- We have a special 'manifest-clean' target, as we can add arbitrarily
  many images to a manifest and don't want the old ones.
  Delete old image in case a regular non-manifest image exists by the
  same name, too.
- The push and image/manifest creation are split, so we can run the
  image creation for more than one architecture and push the combined
  manifest including both.
- We keep `make push` behaving the same to avoid breaking CI.
- Full DOCKER_REPO name is used, as podman-like tools have odd behavior
  with short names.

Signed-off-by: Maya Rashish <mrashish@redhat.com>
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Jul 6, 2022
@kubevirt-bot kubevirt-bot requested review from aglitke and awels July 6, 2022 07:34
hack/sanity.sh Outdated
buildah build -t ${DOCKER_REPO}/sanity:test -f ./sanity/Dockerfile .
# Need privileged so we can bind mount inside container, and hostpath capacity cannot change, so skipping that test
docker run --privileged ${DOCKER_REPO}/sanity:test -ginkgo.noColor -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"
podman run --privileged ${DOCKER_REPO}/sanity:test -ginkgo.noColor -ginkgo.skip="should fail when requesting to create a volume with already existing name and different capacity"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like podman is not installed in this container, this is why the test is failing here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quay.io/kubevirtci/golang is the container that is running this test. Might have to install podman on it during this run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a failed attempt to make the CI image include podman (the kubevirtci kind provider would pick it up but then fail to come up, so it immediately broke some CI lanes), this PR now supports both docker & podman, so CI is now passing with no change to project-infra.

@maya-r
Copy link
Copy Markdown
Contributor Author

maya-r commented Jul 17, 2022

/retest

Signed-off-by: Maya Rashish <mrashish@redhat.com>
@maya-r
Copy link
Copy Markdown
Contributor Author

maya-r commented Aug 2, 2022

ping @awels

Copy link
Copy Markdown
Member

@awels awels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good just have a concern with tls-verify=false being added when pushing.


registry=${IMAGE_REGISTRY:-localhost:$(_port registry)}
DOCKER_REPO=${registry} make push
DOCKER_REPO=${registry} BUILDAH_PUSH_FLAGS="--tls-verify=false" make manifest manifest-push
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why you added the tls-verify=false, because we can't really verify the identity of the registry:5000 in the kubevirtci cluster. Can we only add this flag if we are in that particular situation. I would really like to verify the identity when I am pushing an actual release to quay.io for instance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

hack/k8s-e2e.sh Outdated
registry=${IMAGE_REGISTRY:-localhost:$(_port registry)}
echo "registry: ${registry}"
DOCKER_REPO=${registry} make push
DOCKER_REPO=${registry} BUILDAH_PUSH_FLAGS="--tls-verify=false" make manifest manifest-push
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Add a message about this, too

Signed-off-by: Maya Rashish <mrashish@redhat.com>
@awels
Copy link
Copy Markdown
Member

awels commented Aug 3, 2022

/lgtm
/approve

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2022
@kubevirt-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2022
@kubevirt-bot kubevirt-bot merged commit f24ea1f into kubevirt:main Aug 3, 2022
@awels
Copy link
Copy Markdown
Member

awels commented Jun 16, 2023

/cherrypick release-v0.13

@kubevirt-bot
Copy link
Copy Markdown

@awels: new pull request created: #215

Details

In response to this:

/cherrypick release-v0.13

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.

@awels
Copy link
Copy Markdown
Member

awels commented Jun 16, 2023

/cherrypick release-v0.12

@kubevirt-bot
Copy link
Copy Markdown

@awels: #115 failed to apply on top of branch "release-v0.12":

Applying: Instead of passing environment variables, export them in Makefile
Using index info to reconstruct a base tree...
M	Makefile
Falling back to patching base and 3-way merge...
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Instead of passing environment variables, export them in Makefile
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Details

In response to this:

/cherrypick release-v0.12

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.

awels pushed a commit to awels/hostpath-provisioner that referenced this pull request Jun 16, 2023
* Instead of passing environment variables, export them in Makefile

This passes them to all subprocesses, but they can still be overridden
due to the ?= construct.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Build sanity.test statically

Avoid failure when the binary is built with Fedora 36 and thus
requires newer glibc symbols than the container.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Switch to buildah & podman, enable multi-arch builds

Now we can run:
make clean && \
GOARCH=arm64 make manifest && GOARCH=amd64 make manifest && \
make manifest-push

And spit out a manifest for both arm64 and amd64, in the same image.

Caveats:
- We have a special 'manifest-clean' target, as we can add arbitrarily
  many images to a manifest and don't want the old ones.
  Delete old image in case a regular non-manifest image exists by the
  same name, too.
- The push and image/manifest creation are split, so we can run the
  image creation for more than one architecture and push the combined
  manifest including both.
- We keep `make push` behaving the same to avoid breaking CI.
- Full DOCKER_REPO name is used, as podman-like tools have odd behavior
  with short names.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Tolerate docker instead of podman

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Only add --tls-verify=false if the registry matches localhost*

Add a message about this, too

Signed-off-by: Maya Rashish <mrashish@redhat.com>
awels pushed a commit to awels/hostpath-provisioner that referenced this pull request Jun 16, 2023
* Instead of passing environment variables, export them in Makefile

This passes them to all subprocesses, but they can still be overridden
due to the ?= construct.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Build sanity.test statically

Avoid failure when the binary is built with Fedora 36 and thus
requires newer glibc symbols than the container.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Switch to buildah & podman, enable multi-arch builds

Now we can run:
make clean && \
GOARCH=arm64 make manifest && GOARCH=amd64 make manifest && \
make manifest-push

And spit out a manifest for both arm64 and amd64, in the same image.

Caveats:
- We have a special 'manifest-clean' target, as we can add arbitrarily
  many images to a manifest and don't want the old ones.
  Delete old image in case a regular non-manifest image exists by the
  same name, too.
- The push and image/manifest creation are split, so we can run the
  image creation for more than one architecture and push the combined
  manifest including both.
- We keep `make push` behaving the same to avoid breaking CI.
- Full DOCKER_REPO name is used, as podman-like tools have odd behavior
  with short names.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Tolerate docker instead of podman

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Only add --tls-verify=false if the registry matches localhost*

Add a message about this, too

Signed-off-by: Maya Rashish <mrashish@redhat.com>
awels pushed a commit to awels/hostpath-provisioner that referenced this pull request Jun 17, 2023
* Instead of passing environment variables, export them in Makefile

This passes them to all subprocesses, but they can still be overridden
due to the ?= construct.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Build sanity.test statically

Avoid failure when the binary is built with Fedora 36 and thus
requires newer glibc symbols than the container.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Switch to buildah & podman, enable multi-arch builds

Now we can run:
make clean && \
GOARCH=arm64 make manifest && GOARCH=amd64 make manifest && \
make manifest-push

And spit out a manifest for both arm64 and amd64, in the same image.

Caveats:
- We have a special 'manifest-clean' target, as we can add arbitrarily
  many images to a manifest and don't want the old ones.
  Delete old image in case a regular non-manifest image exists by the
  same name, too.
- The push and image/manifest creation are split, so we can run the
  image creation for more than one architecture and push the combined
  manifest including both.
- We keep `make push` behaving the same to avoid breaking CI.
- Full DOCKER_REPO name is used, as podman-like tools have odd behavior
  with short names.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Tolerate docker instead of podman

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Only add --tls-verify=false if the registry matches localhost*

Add a message about this, too

Signed-off-by: Maya Rashish <mrashish@redhat.com>
kubevirt-bot pushed a commit that referenced this pull request Jun 20, 2023
* Allow dynamic linking of binaries (#205)

* Allow dynamic linking of binaries

The release was creating statically linked binaries
and there is no particular reason for this. Doing
dynamically linked binaries would decrase the container
size.

Signed-off-by: Alexander Wels <awels@redhat.com>

* Updated fedora to 37 so it has a recent enough glibc
Added glibc to the Dockerfile so the binaries can run
Fixed failing functional test that was not calculating
the size properly from the `df -Bk` command. It was
calculating from 1000 instead of 1024 and the size was
wrong because of it.

Signed-off-by: Alexander Wels <awels@redhat.com>

---------

Signed-off-by: Alexander Wels <awels@redhat.com>

* Use buildah instead of docker, support multi-arch builds (#115)

* Instead of passing environment variables, export them in Makefile

This passes them to all subprocesses, but they can still be overridden
due to the ?= construct.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Build sanity.test statically

Avoid failure when the binary is built with Fedora 36 and thus
requires newer glibc symbols than the container.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Switch to buildah & podman, enable multi-arch builds

Now we can run:
make clean && \
GOARCH=arm64 make manifest && GOARCH=amd64 make manifest && \
make manifest-push

And spit out a manifest for both arm64 and amd64, in the same image.

Caveats:
- We have a special 'manifest-clean' target, as we can add arbitrarily
  many images to a manifest and don't want the old ones.
  Delete old image in case a regular non-manifest image exists by the
  same name, too.
- The push and image/manifest creation are split, so we can run the
  image creation for more than one architecture and push the combined
  manifest including both.
- We keep `make push` behaving the same to avoid breaking CI.
- Full DOCKER_REPO name is used, as podman-like tools have odd behavior
  with short names.

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Tolerate docker instead of podman

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Only add --tls-verify=false if the registry matches localhost*

Add a message about this, too

Signed-off-by: Maya Rashish <mrashish@redhat.com>

* Add go mod vendor

Signed-off-by: Alexander Wels <awels@redhat.com>

---------

Signed-off-by: Alexander Wels <awels@redhat.com>
Signed-off-by: Maya Rashish <mrashish@redhat.com>
Co-authored-by: Maya Rashish <mrashish@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants