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

fix: make compatibility versions test use dynamic n-1 branch for test (from hardcoded release-1.31) #33837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aaron-prindle
Copy link
Contributor

@aaron-prindle aaron-prindle commented Nov 25, 2024

Fixes #33573

This PR modifies experiment/compatibility-versions/e2e-k8s-compatibility-versions.sh to fetch the latest release-X.Y branch from https://github.com/kubernetes/kubernetes.git and use that as the n-1 version for compatibility versions testing. This way this test is dynamic and updates the n-1 version as new releases are made - updating automatically over time vs the current hardcoded release-1.31 value currently present in the test.

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aaron-prindle
Once this PR has been reviewed and has the lgtm label, please assign wojtek-t for approval. For more information see the Kubernetes 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/config Issues or PRs related to code in /config area/jobs sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Nov 25, 2024
@aaron-prindle
Copy link
Contributor Author

/cc @BenTheElder

# Clone the specific Kubernetes release branch
clone_kubernetes_release
# Clone the previous versions Kubernetes release branch
# TODO(aaron-prindle) extend the branches to test from n-1 -> n-1..3 as more k8s releases are done that support compatibility versions
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 also think about which branches we're trying to test, if what we're trying to test is the api-server compatibility in master, it might better suit us to use the latest stable tagged patch release in the previous branch for the other components. In practice there's not usually a big distinction anyhow though.

Copy link
Member

Choose a reason for hiding this comment

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

Also, if we did that we could fetch binaries instead of compiling both branches from source.

Copy link
Contributor Author

@aaron-prindle aaron-prindle Nov 26, 2024

Choose a reason for hiding this comment

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

Makes sense, given that it doesn't seem to big a distinction atm perhaps we can keep this as is for now? I created #33594 to track using precompiled binaries so perhaps we can address that in a seperate PR.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I just wanted to point that out, with the precompiled builds we have a bunch of different marker files for the subtle variations depending on what you're actually focusing on testing and how stable you want the other end of the skew.

For now 🤷, let's just get it working, but later we'll want to decide.

git clone --single-branch --branch "${KUBE_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git
get_latest_release_version() {
# Fetch all branch names
git ls-remote --heads https://github.com/kubernetes/kubernetes.git | \
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 probably prefer using local git state?

we can list branches or tags locally and determine this, and it will work in offline development

Copy link
Member

Choose a reason for hiding this comment

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

actually, further, to make this work with N branches, it should look at something like git describe, get the current release branch from that and then compute the N-... branch.

Because we'll want to be running this on each release going forward and those can't just assume the target is the latest release at all.

Copy link
Contributor Author

@aaron-prindle aaron-prindle Nov 26, 2024

Choose a reason for hiding this comment

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

Does the k8s repo that Prow pulls have all of the other branches available? If so, definitely +1 - just want to confirm that. We pass in base_ref: master as part of the k8s/k8s repo config so wasn't sure if all branches were pulled down.

# Clone the specific Kubernetes release branch
clone_kubernetes_release
# Clone the previous versions Kubernetes release branch
# TODO(aaron-prindle) extend the branches to test from n-1 -> n-1..3 as more k8s releases are done that support compatibility versions
Copy link
Member

Choose a reason for hiding this comment

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

Also, if we did that we could fetch binaries instead of compiling both branches from source.

# Clone the previous versions Kubernetes release branch
# TODO(aaron-prindle) extend the branches to test from n-1 -> n-1..3 as more k8s releases are done that support compatibility versions
export PREV_RELEASE_BRANCH="release-${EMULATED_VERSION}"
git clone --single-branch --branch "${PREV_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git "${PREV_RELEASE_BRANCH}"
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need another full clone? (also if we're going to clone, we should add some performance related flags, cloning kubernetes in full is really expensive with the 10 years of history)

If we need to use git, let's use a worktree. But I think we can fetch binaries for the old release and for the new release we should already have the checkout in order, presumably.

Copy link
Contributor Author

@aaron-prindle aaron-prindle Nov 26, 2024

Choose a reason for hiding this comment

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

+1, I'm familiar with some of the flags to pull branch with minimal history (--depth=1, --single-branch) which I've changed this to use now. Did you have any other suggestions for flags there?

Can you explain how a worktree would help in this context or give an example for what you are suggesting with If we need to use git, let's use a worktree.? Thanks

Copy link
Member

@BenTheElder BenTheElder Nov 27, 2024

Choose a reason for hiding this comment

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

+1, I'm familiar with some of the flags to pull branch with minimal history (--depth=1, --single-branch) which I've changed this to use now. Did you have any other suggestions for flags there?

--depth=1 will break git describe (it has to walk back to find the last tag), in prow we use --filter=blob:none instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah got it, I've updated this to use --filter=blob:none now:

  git clone --filter=blob:none --single-branch --branch "${PREV_RELEASE_BRANCH}" https://github.com/kubernetes/kubernetes.git "${PREV_RELEASE_BRANCH}"

@BenTheElder
Copy link
Member

BenTheElder commented Nov 25, 2024

TLDR I think:

  • let's determine which release we're on currently by using hack/print-workspace-status.sh (so single source of truth about kube versioning from the main repo), that way this script "just works" for 1.32, 1.33, 1.34, ... (instead of floating with the current latest)
  • then we can compute the N-1 or N-2 release minor version (maybe we should make the constant minor back-compat offset a variable with a default of 1 or 2?)
  • we can then do kind build node image v1.N-1.(latest) (TODO: we can get latest from git tag | grep 'v1.N-1.' ?)
  • create kind cluster from this image, ensure --compat-version is set to N-1
  • then we can build and patch in api-server from the current branch
  • run tests from N-1 ? (we can also download these the same as kind downloading the component release binaries)

@aaron-prindle
Copy link
Contributor Author

aaron-prindle commented Nov 26, 2024

  • let's determine which release we're on currently by using hack/print-workspace-status.sh (so single source of truth about kube versioning from the main repo), that way this script "just works" for 1.32, 1.33, 1.34, ... (instead of floating with the current latest)
    Ah I didn't know about hack/print-workspace-status.sh, thanks! I've updated the logic here to use that script vs looking at the git remote information.
  • then we can compute the N-1 or N-2 release minor version (maybe we should make the constant minor back-compat offset a variable with a default of 1 or 2?)
    Currently I've updated this PR to compute only the N-1 release minor version as v1.31-v1.32 are the only versions support for Compatibility Versions currently

Currently the PR is focused on fixing #33573. I've created #33849 to track the issue with the kubelet version being incorrect. I will address the below points in a separate PR to fix #33849 if that is ok. Can also do them both in the PR, currently my plan is to do them in 2 PRs though.

  • we can then do kind build node image v1.N-1.(latest) (TODO: we can get latest from git tag | grep 'v1.N-1.' ?)
  • create kind cluster from this image, ensure --compat-version is set to N-1
  • then we can build and patch in api-server from the current branch
  • run tests from N-1 ? (we can also download these the same as kind downloading the component release binaries)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config Issues or PRs related to code in /config area/jobs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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
3 participants