Skip to content

Download all binaries instead of building them locally for compat version tests #34930

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

michaelasp
Copy link
Contributor

This pr downloads all required docker and test binaries and uses those to run the tests rather than building them locally. Running these tests locally showed a major performance improvement from this.

The two major changes are downloading all the control plane docker images rather than building them from source and also downloading the test binaries instead of building them to run conformance tests.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 5, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @michaelasp. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: michaelasp
Once this PR has been reviewed and has the lgtm label, please assign aaron-prindle for approval. For more information see the Code Review Process.

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

@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Jun 5, 2025
@michaelasp
Copy link
Contributor Author

/cc @BenTheElder

build_docker(){
build/run.sh make all WHAT="cmd/kubectl cmd/kubelet" 1> /dev/null
make quick-release-images 1> /dev/null
download_docker(){
Copy link
Member

Choose a reason for hiding this comment

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

this name is misleading (the old one is too, it's a carry over from when we had a bazel build mode, but this is even more misleading)

maybe "download_images"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

}

download_current_version_bins() {
wget https://dl.k8s.io/ci/$(curl -Ls https://dl.k8s.io/ci/latest.txt)/kubernetes-test-$(go env GOOS)-$(go env GOARCH).tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

maybe something like this:

Suggested change
wget https://dl.k8s.io/ci/$(curl -Ls https://dl.k8s.io/ci/latest.txt)/kubernetes-test-$(go env GOOS)-$(go env GOARCH).tar.gz
wget 'https://dl.k8s.io/ci/'"${1}"/'kubernetes-test-'"$(go env GOOS)-$(go env GOARCH)"'.tar.gz'

and pass in the version (see below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, this can make for some nasty edge cases. I made it so only the create_cluster step obtains the latest_version. I think that's the best place to put it in common.sh since we need to create a cluster in every test and we have access to artifacts at that point.

@@ -235,6 +235,30 @@ build_prev_version_bins() {
echo "Finished building e2e.test binary from ${PREV_RELEASE_BRANCH}."
}

download_prev_version_bins() {
local version=$1
wget https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable-${version}.txt)/kubernetes-test-$(go env GOOS)-$(go env GOARCH).tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

TODO: this script as-written will only work on a linux host, but it should work on mac too.

For that you need to split binaries being downloaded for kind (GOOS should always be linux) versus for the host (like the test binaries)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a todo :)

@@ -32,8 +32,9 @@ CONTROL_PLANE_COMPONENTS="kube-apiserver kube-controller-manager kube-scheduler"
KUBE_ROOT="."
# KUBE_ROOT="$(go env GOPATH)/src/k8s.io/kubernetes"
source "${KUBE_ROOT}/hack/lib/version.sh"
kube::version::get_version_vars
DOCKER_TAG=${KUBE_GIT_VERSION/+/_}
LATEST_IMAGE=$(curl -Ls https://dl.k8s.io/ci/latest.txt)
Copy link
Member

Choose a reason for hiding this comment

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

we should make sure to use this value when downloading the current version, otherwise we're going to wind up with a race where we record one version and test another.

Suggested change
LATEST_IMAGE=$(curl -Ls https://dl.k8s.io/ci/latest.txt)
LATEST_VERSION=$(curl -Ls https://dl.k8s.io/ci/latest.txt)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, made it so only the common script modifies it in the create cluster step.

@BenTheElder
Copy link
Member

Thanks, sorry for the delay (PRR crunch...), some comments above ...

make quick-release-images 1> /dev/null
download_docker(){
curl -L 'https://dl.k8s.io/ci/'${LATEST_IMAGE}'/kubernetes-server-linux-amd64.tar.gz' > kubernetes-server-linux-amd64.tar.gz
tar -xvf kubernetes-server-linux-amd64.tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

You probably want to stage files in a tempdir instead of in the current working directory, it can make the repo dirty (also, they might not get cleaned up ...)

This server tarball can also be used to build a node image, so we don't need to checkout and build k/k at all.

kind build node-image --type file kubernetes-server-linux-amd64.tar.gz
https://kind.sigs.k8s.io/docs/user/quick-start/#building-images

Copy link
Contributor Author

@michaelasp michaelasp Jun 10, 2025

Choose a reason for hiding this comment

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

Done! I don't think we build k/k at all here, the create cluster step uses a precompiled image. I did however remove the cloning of the k8s repo, this is no longer necessary since we pull the precompiled binary.

@michaelasp
Copy link
Contributor Author

/cc @Jefftree

@k8s-ci-robot k8s-ci-robot requested a review from Jefftree June 17, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants