Repository navigation
cephadm: optionally pre-pull upgrade image on in-scope hosts - #70314
kginonredhat wants to merge 5 commits into
Conversation
21b26e4 to
ee6c8ae
Compare
92295d1 to
880a2f2
Compare
|
jenkins test make check |
|
jenkins test api |
|
jenkins test dashboard cephadm |
|
jenkins test windows |
|
@kginonredhat Thanks for building on my earlier work (#69358) and for the credit in the commit message — the mirror idea is a nice extension, particularly for air-gapped clusters and setups where the registry is remote or bandwidth-constrained: hitting the registry only once is a real improvement in those cases. 👍 I have a few concerns from reading the code, mostly around the seed host's network saturation:
Would you consider adding a per-host rate limit (e.g.
Since
|
880a2f2 to
9d95fe7
Compare
regarding #3 Compressing the image while saving it regarding having the Direct pre-pull option - i do not see a good use case for this, regarding the rate limit - indeed good idea , although i doubt someone will use it if no issue's, |
|
Thanks for taking the compression and rate-limit suggestions on board 👍 On the direct pre-pull, I think we're talking past each other, so let me clarify: I was not referring to pulling from the Internet. I was referring to pulling from a customer-side local registry (Harbor, Quay, Artifactory mirror…), which is a very common setup — it's even the documented cephadm approach for isolated environments (the local "registry mirror" from the docs). In that topology, every node already has connectivity to the local registry (that's what it's for), and the registry natively serves N parallel pulls — typically as fast as or faster than a single seed node, which becomes the bottleneck and a SPOF for the distribution phase. So the two modes really map to two different topologies, both real:
Your current code covers the second case well, but leaves the first with nothing: with On "fewer options": fair point in general, but I'd argue this isn't two options for one path — it's one option per topology. Happy to keep it minimal: a single |
9d95fe7 to
03ac49c
Compare
well thanks for the explanation |
|
I agree. Rate limiting might only be necessary when pulling directly from a Ceph node to protect its services, but even that we don't know yet. If we're pulling from a local registry outside the Ceph cluster, rate limiting is for sure pointless and will just artificially slow down the transfer. 👍 |
cf3c635 to
d24df58
Compare
ccde7bb to
07a0f6f
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
1 similar comment
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
07a0f6f to
580a903
Compare
|
hi @rkachach (cc @reduane) — addressed the latest feedback; the branch is force-pushed as 4 commits and the full cephadm unit suite is green (1770 passed): Blockers
Should-fix
New/updated tests include Also re-validated end-to-end on the 3-node kcli cluster with the rebased code (details in the PR description): pre-pull before any daemon upgrade, timeout/ please review thx |
580a903 to
f0a0fd0
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
f0a0fd0 to
86e4306
Compare
|
jenkins test make check |
|
hi @rkachach — rebased onto latest main (branch is now |
adk3798
left a comment
There was a problem hiding this comment.
Overall LGTM, my comments are fairly specific. I think we should also add this to our upgrade test suite. An equivalent to what we do her https://github.com/ceph/ceph/tree/main/qa/suites/orch/cephadm/upgrade/2-repo_digest for testing with and without repo_digest. Otherwise we risk breaking the feature since all testing would be with it off.
|
|
||
| def get_upgrade_scope_hosts(self, daemons: List[DaemonDescription]) -> List[str]: | ||
| hosts = sorted({d.hostname for d in daemons if d.hostname}) | ||
| return [h for h in hosts if h not in self.mgr.offline_hosts] |
There was a problem hiding this comment.
If we're removing offline hosts from this list (upgrade blocks if there's an offline host iirc but one could go offline right after triggering the upgrade) we should probably remove hosts in maintenance mode as well.
There was a problem hiding this comment.
done — get_upgrade_scope_hosts() now also skips hosts in maintenance (inventory.get_host_with_state('maintenance')), same as offline hosts. covered by test_get_upgrade_scope_hosts_skips_offline_and_maintenance; doc updated to mention it.
| return False | ||
|
|
||
| async def _registry_login_if_needed(self, host: str) -> None: | ||
| if self.mgr.cache.host_needs_registry_login(host) and self.mgr.registry_url: |
There was a problem hiding this comment.
the registry_url config option stopped being the place to store this back in 2c29286 and only wasn't removed because we needed it to still exist to handle the migration (given how many releases ago it was we could probably now remove it though). Currently what you need to check for credentials is self.mgr.get_store('registry_credentials'). Looking at the code I can see we're still checking the old config option in a number of spots. The handling of the login in _refresh_hosts_and_daemons in serve.py uses the correct check but the other two spots that use self.mgr.registry_url like being done here I assume just never pass the conditional and the login only gets handled at that one spot using get_store. I actually missed it myself while working on #73500. For now maybe just use the get_store check and I can cleanup the registry_url checks as part of that PR since it also introduces a new mgr attr that should actually be populated (and can handle that we allow multiple registries in the login command).
There was a problem hiding this comment.
good catch — _registry_login_if_needed() now uses the get_store('registry_credentials') check (same as _refresh_hosts_and_daemons in serve.py); the legacy registry_url condition is gone from the new code. covered by test_registry_login_if_needed_uses_stored_credentials. thanks for offering to clean up the remaining registry_url checks in #73500.
| f'failed to pull image on {host}: {reason}' | ||
| for host, reason in failed_hosts | ||
| ] | ||
| self.upgrade._fail_upgrade('UPGRADE_FAILED_PULL', { |
There was a problem hiding this comment.
Nothing to act on but just making a mental note this will be the only place outside of upgrade.py that actually can fail the upgrade. I can't think of anywhere else for this to live though so it's fine.
There was a problem hiding this comment.
ack — yes, for now _fail_upgrade() stays in upgrade.py and image_prepull only calls into it from the batch-harvest path on the serve thread.
| # ignore it and start ours on a later iteration | ||
| return None | ||
| self._first_pull_future = None | ||
| self.first_pull_host = self.mgr._any_inventory_host() |
There was a problem hiding this comment.
I don't really understand how this first_pull_host is being used. We set this and then call _first_pull_async which calls _get_container_image_info. _get_container_image_info doesn't take a host as an argument and picks any host itself. I assume it works in practice since it picks the host the same way, but if we're going to pick out a host here it feels like we should be able to pass that along
There was a problem hiding this comment.
agreed — _get_container_image_info() now takes an optional host argument (defaulting to the old _any_inventory_host() pick when not given), and first_pull_start_or_poll() passes the host it recorded through to the pull. so first_pull_host is now the host the pull actually ran on instead of relying on both sides picking the same host independently. covered by assertions in test_first_pull_background_when_prepull_enabled.
| target_id, target_version, target_digests = value | ||
| first_host = self.image_prepull.first_pull_host | ||
| else: | ||
| first_host = self.mgr._any_inventory_host() |
There was a problem hiding this comment.
what is first_host doing in the non pre-pull case?
There was a problem hiding this comment.
nothing — leftover from an earlier iteration, removed. in the non pre-pull case _get_container_image_info() picks its host internally exactly as it did before this PR.
|
thanks @adk3798! added all inline comments addressed in b9b6102 (replies inline); full cephadm unit suite green locally (1863 passed, 1 skipped), flake8 clean vs baseline. | jenkins test make check | |
|
Hey @kginonredhat, thanks for driving this forward! Since the pre-pull feature started from my original patch, would you mind adding me to the main feature commit ( |
|
hi @FredNass — done, and thank you for the original work this started from! the feature commit ( (message-only change; no code differences — |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
_run_cephadm_json now accepts a timeout and forwards it to _run_cephadm, which already knows how to pass it to the remote cephadm binary. _get_container_image_info gains a matching optional timeout, and the repeated "pick a random host" snippet is factored into CephadmOrchestrator._any_inventory_host(). EventLoopThread gains spawn(), a fire-and-forget counterpart to get_result() that starts a coroutine on the cephadm event loop and returns a thread-safe future to poll for completion without blocking the caller and without cancelling the coroutine on a timeout. Passing timeout=None (the default) preserves the previous behavior, so callers that do not care are unaffected. Signed-off-by: Kobi Ginon <[email protected]>
Pull the ``target_version.split(' ')[2]`` snippet at the end of the
first pull into _short_ceph_version(), and the two 'Upgrade: Target
is ...' log lines into _announce_target().
Short version strings that do not start with 'ceph version' used to be
split on whitespace and could raise IndexError or store a wrong token;
they now pass through unchanged, and unusable input is reported as
'unable to extract ceph version from container' instead.
Signed-off-by: Kobi Ginon <[email protected]>
Add an opt-in upgrade_prepull_image mode that pulls the upgrade target image on every in-scope host from the cluster registry before any daemon is upgraded. Pulls never block the serve loop: the metadata first pull and each parallel batch (bounded by upgrade_prepull_max_parallel) run as background tasks on the cephadm event loop (EventLoopThread.spawn), and the serve thread only starts them and polls for results on later serve iterations. All upgrade-state mutation (marking hosts done, failing the upgrade) happens on the serve thread when results are harvested, so refresh, deploys and health checks keep running and `ceph orch upgrade pause/stop` keep working while pulls are in flight. Results of a batch whose upgrade was stopped, replaced or paused in the meantime are discarded; after a resume the affected hosts are pulled again, which is cheap for images already present. Completed hosts are recorded in the upgrade state and skipped after a pause or mgr failover; in-flight handles do not survive an mgr restart, so remaining hosts are simply pulled again. A failure on any host (pull error, digest mismatch, or batch timeout) pauses the upgrade before any daemon is touched. The existing first/validation pull on one host still learns the target digest and Ceph version (and rejects a bad target) before the cluster-wide pre-pull. It keeps the normal command timeout in the CLI validation path so `ceph orch upgrade start` cannot hang behind the long pull timeout; in serve, when pre-pull is enabled, it runs in the background with the configurable upgrade_prepull_timeout (default 7200s, bounded at the mgr side by a 60s margin) and its result is reused so staggered upgrades do not pull twice. Staggered upgrades pre-pull only on hosts in the current upgrade scope. When the option is disabled the upgrade path is unchanged. Co-authored-by: Frédéric Nass <[email protected]> Signed-off-by: Kobi Ginon <[email protected]>
Document the mgr/cephadm/upgrade_prepull_image option and its tuning knobs (upgrade_prepull_max_parallel, upgrade_prepull_timeout), including that pulls run as background tasks and never block the mgr serve loop, and that orch upgrade pause/stop keep working while pulls are in flight. Signed-off-by: Kobi Ginon <[email protected]>
Fix two issues in the upgrade image pre-pull feature found in review:
While a background pre-pull was in flight, continue_upgrade() returned
True ("did work"), so the serve loop skipped _serve_sleep() and re-ran
the whole serve body back to back for the entire pre-pull phase (up to
upgrade_prepull_timeout + 60 seconds per pull, across all sequential
batches). continue_upgrade() now reports "nothing was done" while a
pull is pending, so the serve loop sleeps at its normal interval, and
a done-callback on the pull future sets mgr.event to wake the loop as
soon as the pull finishes: no busy loop and no extra polling delay.
`ceph orch upgrade stop` left in-flight pre-pull coroutines running.
Because the pre-pull origin key includes the upgrade progress id, a
following `ceph orch upgrade start` (even to the same image) could not
start its own pulls until the abandoned ones finished or timed out,
while they kept pulling an image nobody asked for on up to
upgrade_prepull_max_parallel hosts. upgrade_stop() now cancels and
forgets in-flight pulls via UpgradeImagePrePull.reset(), so the next
upgrade starts pre-pulling right away.
Signed-off-by: Kobi Ginon <[email protected]>
Opt-in upgrade image pre-pull before any daemon is upgraded.
Fixes: https://tracker.ceph.com/issues/77270
Based-on-patch-by: Frédéric Nass [email protected]
Signed-off-by: Kobi Ginon [email protected]
Today, cephadm pulls the target Ceph container image on each host on demand during upgrade. On large clusters / large images this adds significant time (and for MDS can extend CephFS unavailability after
fs fail/ scale-down).This feature only pre-pulls the Ceph upgrade target image (the one from
ceph orch upgrade start --image …).It does not cover Grafana / monitoring or SMB images.
mgr/cephadm/upgrade_prepull_imagefalse(default)trueAlso:
EventLoopThread.spawn()); the serve thread only starts them and polls for results on later serve iterations. Host refresh, service deployment and health checks keep running, andceph orch upgrade pause/stopkeep working while pulls are in flight.ceph orch upgrade startkeeps the normal command timeout for the CLI validation pull, so a scoped start cannot hang the client behind the long pre-pull timeout; the long-timeout pull runs in the background in serve.target_image_pre_pull_hostsin upgrade state (survives mgr failover and pause); in-flight handles do not survive an mgr restart, so remaining hosts are simply pulled again.UPGRADE_FAILED_PULLif pre-pull fails (pull error, digest mismatch, or batch timeout) — no daemons upgraded yet.src/pybind/mgr/cephadm/image_prepull.pydoc/cephadm/upgrade.rstScope: applies to the Ceph upgrade target image only (
ceph orch upgrade start --image …). Monitoring stack images (Grafana/Prometheus/…) and SMB/NVMeoF images are separate (NON_CEPH_IMAGE_TYPES) and are not pre-pulled by this feature.Commit split
mgr/cephadm: forward timeouts through _run_cephadm_json— timeout plumbing +EventLoopThread.spawn()+ test_cephadm.py mock updatesmgr/cephadm: centralize upgrade target version parsing—_short_ceph_version()/_announce_target()refactor + testmgr/cephadm: optionally pre-pull upgrade image on in-scope hosts— the feature, options, wiring and testsdoc/cephadm: document upgrade image pre-pull— docsConfig
Verified test case (kcli 3-node cluster, 2026-10-29, rebased code)
Environment: ceph-node-0/1/2 (mon×3, mgr×2, osd×3 = 11 daemons), all daemons on
192.168.210.254:5000/ceph/ceph:main(v22.0.0-6-gc57633a6, imagef70b27f1e4a4); target image192.168.210.254:5000/ceph/ceph:main-rebase-prepull(image927d2a7a6ed8, same Ceph version, different digest) pushed to the local registry but not pulled on any host; mgr running the PR code.Configuration and start:
Observed results (mgr journal + per-host cephadm.log):
ceph orch upgrade statusshows"message": "Pre-pulling upgrade image on 3/3 host(s)"with"progress": "0/11 daemons upgraded".Upgrade: registry pre-pull using 7200 second cephadm pull timeout; each host'scephadm.logshows the pull issued ascephadm ['--image', …, '--timeout', '7200', 'pull'].upgrade starton the first inventory host is counted as already done —Upgrade: pre-pulling image …@sha256:7098775f… on 2 host(s) this serve iteration (1/3 already done)(no duplicate pull on that host).Upgrade: registry pre-pull complete.podman images) while every daemon still ran the old image.mgr→mon/crash→osd), finishing at11/11 daemons upgraded→Upgrade: Complete!→There are no upgrades in progress currently.The upgrade also survived a mid-upgrade mgr failover (node-0's mgr was upgraded first; node-1's mgr took over and completed the upgrade).192.168.210.254:5000/ceph/ceph@sha256:7098775f…,ceph -shealthy (3 mons in quorum, 3 osds up/in, pgs active+clean), consistentceph versions.Same-image start (no regression)
With all daemons already on that image: the validation pull runs, pre-pull completes as a fast no-op batch, no image-driven daemon redeploys happen, and the upgrade completes (
Upgrade: Complete!).Checklist