Skip to content
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

cleanup(vpa): remove go vendoring #7572

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

davidspek
Copy link
Contributor

@davidspek davidspek commented Dec 5, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR removes the vendor directories for the VPA. Vendoring the dependencies into the repo not only increases the size, but also makes reviewing PRs that include dependency changes more difficult. Sometimes to the point of breaking the GitHub UI like in #7551 and likely this PR. The relevant Dockerfiles have been updated to function without the vendor directory and maximize layer caching. Along with that, the final image was change to gcr.io/distroless/static:nonroot so the containers don't run as root used by default.

Which issue(s) this PR fixes:

Fixes #7570

Special notes for your reviewer:

The hack/update-codegen.sh script will need to be modified. However, doing so with the current version and this change is quite difficult. So I would like to postpone this to the PR that updates the k8s dependencies.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 5, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @davidspek. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 5, 2024
@adrianmoisey
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 5, 2024
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 5, 2024
@davidspek
Copy link
Contributor Author

/assign raywainman

@adrianmoisey
Copy link
Member

/lgtm

e2e tests still pass locally 👍

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2024
COPY . /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler
WORKDIR /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler
# Copy the Go Modules manifests
COPY go.mod go.mod
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we replace all these copy statements with just one?

COPY . .

Similar to https://github.com/GoogleContainerTools/distroless?tab=readme-ov-file#examples-with-docker?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for these separate copy statements is to maximize layer caching. First copying the go.mod and go.sum and then downloading the dependencies before before copying any application code allows the layer containing all the dependencies to be cached during a container build. This can make a big difference for build times, especially when doing development. For this same reason the Go code is being explicitly copied into the container instead of a more global copy so that changes to other files (or the addition of new ones) that aren't part of the codebase don't trigger a new image build. Technically this could also be done with a .dockerignore file, but then any new files or directories would need to be added there, and in my opinion having it copied in the Dockerfile explicitly also helps for clarity. This is also the standard way Dockerfiles are created for projects using kubebuilder and I believe can be seen as best practice.

Copy link
Member

@adrianmoisey adrianmoisey Dec 6, 2024

Choose a reason for hiding this comment

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

What about:

COPY go.mod go.sum .

And later:

COPY common pkg .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should also work, although technically a little less good for layer caching.

Copy link
Member

Choose a reason for hiding this comment

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

Since both operations are a copy, I don't think there will be a noticeable different to the user if one those layers had to be re executed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raywainman What's your view on this? I'd like to get this sorted so it can be merged and we can move forward with the dependency upgrade PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Layer caching seems like a reasonable reason to do this. LGTM.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 6, 2024
@adrianmoisey
Copy link
Member

I'm going to /lgtm
I don't have strong opinions about the Dockerfile COPY

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2024
@davidspek davidspek force-pushed the feat/vpa-remove-go-mod branch from e1d544c to 82908da Compare December 6, 2024 14:16
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2024
@raywainman
Copy link
Contributor

/lgtm

/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidspek, raywainman

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 9, 2024
@k8s-ci-robot k8s-ci-robot merged commit dda0dc8 into kubernetes:master Dec 9, 2024
7 checks passed
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. area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VPA: Remove the vendor dir
4 participants