Refactor download (file) - #12299
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: VannTen The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Also, I think the approach could make manage-offline.sh redundant (aka, just run the download tags on a non offline control node, copy the local_release_dir, done)
I'm not super into that so might not be enough though
|
631adb1 to
984a759
Compare
cace245 to
7241144
Compare
f82c321 to
86be1af
Compare
90b55a0 to
9dc42ee
Compare
edc1223 to
4ceb0be
Compare
|
These failing maybe are related with docker in conformance test. |
|
The trigger was support for K8s 1.36, it fails only after that (looking at gitlab pipelines history)
Unless there are objections I'm gonna send a PR to put this in manual tests, and I'd like to try to merge both download PR before September or sooner.
AFAIK there is only the semaphore issue (Ansible bug with async on semaphoreui) which has a workaround.
The PR also fixes a number of bugs and we're kinda blocking other fix PR (incompatible ones) waiting for it.
And if I could stop rebasing and handling conflict that'd be nice :) (I need to test the giraffe merge thing...)
|
This is the same logic as system_packages: we simply let jinja expand our variables to a list of boolean and filter on this.
- Remove the various variable concerning download delegation to keep only
`download_delegate`.
- Only use one task with a loop to download all artefacts, computing the
loop from hostvars[*]['downloads'] (aka, we compute the set of
all needed artefacts across the nodes delegating to a particular host)
The implementation is optimized towards the `download_delegate ==
'localhost'` case, but retains backwards compatibility for other value
of `download_delegate`.
Small efficiency gains when downloading, around 2-3s worse when everything is already there.
- The download/file role needs to run on localhost as well because it does not use delegate_to directly, each host scans hostvars to determine what downloads are delegated to it by other hosts. - We also needs to collect facts for localhost to have the downloads correctly processed here (machine architecture etc)
local_release_dir has insufficient nuances, as it needs to handle several cases, - where to put downloaded artifacts - where to search for when installing artifacts - where to search for when using artifacts (passing them via lookup to kubectl stdin for instance) Furthermore, depending on how the user set up download delegation, the value we want can be on the host the tasks is executing, on the delegated hosts, etc. Define variables on top of local_release_dir for differents contexts, handling which host context to use depending on `download_delegate`. Mostly, this boils down to choosing the correct `host` for hostvars[host]['local_release_dir']. download: use a dedicated variable as source when installing artefacts Avoid problem if local_release_dir differs between localhost and other hosts.
The current way of installing ArgoCD from downloaded manifests does not work well with the new download/file role. Additionally, usage of our internal `kube` Ansible module is deprecated. Rewrite ArgoCD install to use kubectl_apply_stdin directly without pushing manifests to the control plane node first. ansible-lint: the refactor apparently newly exposes the password hash filter to ansible and this needs passlib, so add it to the pre-commit dependencies.
bb757be06 (Convert argocd to kubectl apply stdin, 2025-07-08) removes the only task using yq on host, so remove it completely.
- Use only one task with loop instead of dedicated roles - don't copy manifest to control plane, use kubectl_apply_stdin instead - delete duplicates defaults from gateway_api (exists in kubespray_defaults) - Add version to prometheus-operator and gateway-api crds manifests (allows uniqueness)
- avoids the needs to create the directory. - convert to new download/file role.
The objective is to have 3 tasks only (usually two): - fetching the artifact on download_delegate (can be same host) - (optionnal) fetch back to localhost (this is only needed when download_delegate is not the same host, and not localhost) - install directly (no need for a local staging directory on nodes) The third item in particular avoid needless copy on the managed nodes on potentially space constrained filesystems. crio: group the 3 tasks handling artifacts installation (binaries, service file, default policy) together for clarity.
This is needed for being able to filter on "not container" cleanly.
Move out kubeadm install out of the legacy download role and into its own role.
skopeo is required to load image from archive anywhere cri-o is used (since the latter lacks a way to do this natively, since load/save commands are not part of the Kubernetes CRI interface) Since we now rely on the downloads variable instead of manually downloading skopeo, fix the inconsistency.
670d858 (download: rewrite file downloads, 2025-06-09) removed the code using that data, so remove the fields.
Previously, kubespray created local_release_dir as root unnecessarily, so we need to fix the permissions. The simplest way it to provide a way for users to remove the directory entirely. Since the default value is /tmp/releases and in most Linux distribution /tmp should be cleaned after some days by systemd-tmpfiles, in most cases this should not be needed.
The file artefacts are handled by the new download/file role
The molecule_run.sh isn't really needed since the switch to gitlab-ci matrix runs.
|
I test-merged this against #13397 and ran a full install + upgrade on 6 VMs. Two things I hit 1.
|
|
Thanks for the testing, I'll address those and the one in the other PR,
time permitting.
…--
Max Gautier
|
|
By the way, how should I test this download refactor PR? It looks like some parts still need to be adjusted. |
|
PR needs rebase. DetailsInstructions 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. |
What type of PR is this?
/kind bug
/kind feature
What this PR does / why we need it:
This should fix multi-arch cluster download, and be much more scalable. (rough testing of the file part only:
-> around 1 minutes for 1000 fake hosts with download_delegate == localhost)
This is only the file part, I plan to handle containers images in a separate PR.
This is a full rewrite of the file part of the
downloadrole.This massively improves the runtime of the playbooks (our CI jobs appears to go from 9 to 6 minutes), and should also fix or at least improve a lot the situation with multi-architecture clusters (but that will need the follow-up handling container for that usecase), because the downloads are now calculated per host, before deduplication to the host handling the download if there is delegation.
The improvement mostly comes from dropping the
include_tasks: download_file.ymlwith a loop on download, dropping unnecessary tasks and pre-processing the loop (so, there should not be any skipped tasks, because they are removed of the list before being passed toloop).The uniqueness of binaries rely on the filename, so using the correct variable inside the downloads variable (architecture / os_version / etc) should suffice.
This also removes all of the
includeused in various roles to reuse part of the download role. Now only the downloads role is responsible for getting artefacts, which should help with skipping with --tags and similar.Which issue(s) this PR fixes:
Fixes #12403
Fixes #13086
Special notes for your reviewer:
There will be a follow-up to handle the container part as well, with the same ideas
After this is merged, and I'll also handle the container download part (which should be easier as a good chunk of the logic around delegation will be reused), I plan to default
download_delegatetolocalhost.This will be a breaking change, moreso than the existing one in the release-note, because it will change behavior, not just interface.
I wanted to keep it separate for that reason.
Much of the complexity of the new role is for handling
download_delegate != inventory_hostname || 'localhost'which is the current default (delegate to first control plane).NOTE: The release-note also take into account #12937 which will need to be merge for fully removing the listed variables.
I tried to keep this not too big, but unfortunately it touched on a lot of assumptions / weird stuff in Kubespray. If you see something which could be split out do not hesitate to point it out, I'll try to extract it in a new PR (or if you have the energy feel free to do it directly ^)
Does this PR introduce a user-facing change?: