Skip to content

cephadm: optionally pre-pull upgrade image on in-scope hosts - #70314

Open
kginonredhat wants to merge 5 commits into
ceph:mainfrom
kginonredhat:issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade
Open

kginonredhat wants to merge 5 commits into
ceph:mainfrom
kginonredhat:issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade

Conversation

@kginonredhat

@kginonredhat kginonredhat commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

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_image Behavior
false (default) Disabled (current behavior)
true After the existing serial first pull (digest + Ceph version), pull in parallel batches on remaining in-scope hosts from a reachable registry (Harbor/Quay/local registry).

Also:

  • Pulls never block the serve loop: the metadata first pull and each parallel batch run as background tasks on the cephadm event loop (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, and ceph orch upgrade pause / stop keep working while pulls are in flight.
  • All upgrade-state mutation happens on the serve thread when batch results are harvested; 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 — cheap for already-present images).
  • ceph orch upgrade start keeps 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.
  • Persist target_image_pre_pull_hosts in upgrade state (survives mgr failover and pause); in-flight handles do not survive an mgr restart, so remaining hosts are simply pulled again.
  • Pause with UPGRADE_FAILED_PULL if pre-pull fails (pull error, digest mismatch, or batch timeout) — no daemons upgraded yet.
  • Pre-pull implementation lives in src/pybind/mgr/cephadm/image_prepull.py
  • Docs: doc/cephadm/upgrade.rst

Scope: 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

  1. mgr/cephadm: forward timeouts through _run_cephadm_json — timeout plumbing + EventLoopThread.spawn() + test_cephadm.py mock updates
  2. mgr/cephadm: centralize upgrade target version parsing — _short_ceph_version() / _announce_target() refactor + test
  3. mgr/cephadm: optionally pre-pull upgrade image on in-scope hosts — the feature, options, wiring and tests
  4. doc/cephadm: document upgrade image pre-pull — docs

Config

# enable parallel registry pre-pull
ceph config set mgr mgr/cephadm/upgrade_prepull_image true

# optional tuning: hosts pulled per serve iteration (default 8)
ceph config set mgr mgr/cephadm/upgrade_prepull_max_parallel 8

# optional tuning: per-host pull timeout in seconds (default 7200)
ceph config set mgr mgr/cephadm/upgrade_prepull_timeout 7200

# disable
ceph config set mgr mgr/cephadm/upgrade_prepull_image false

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, image f70b27f1e4a4); target image 192.168.210.254:5000/ceph/ceph:main-rebase-prepull (image 927d2a7a6ed8, same Ceph version, different digest) pushed to the local registry but not pulled on any host; mgr running the PR code.

Configuration and start:

ceph config set mgr mgr/cephadm/upgrade_prepull_image true
ceph orch upgrade start --image 192.168.210.254:5000/ceph/ceph:main-rebase-prepull

Observed results (mgr journal + per-host cephadm.log):

  1. Pre-pull phase runs before any daemon upgrade: ceph orch upgrade status shows "message": "Pre-pulling upgrade image on 3/3 host(s)" with "progress": "0/11 daemons upgraded".
  2. Configurable timeout honored: mgr logs Upgrade: registry pre-pull using 7200 second cephadm pull timeout; each host's cephadm.log shows the pull issued as cephadm ['--image', …, '--timeout', '7200', 'pull'].
  3. First-host reuse: the inspect-image pull performed by upgrade start on 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).
  4. Parallel pull of remaining hosts: pull commands issued to ceph-node-1 and ceph-node-2 at the same second (digest-pinned image), both completing ~2s later.
  5. Digest verification: pulled digests compared against the target image digests (no mismatch), then Upgrade: registry pre-pull complete.
  6. Target image present on all 3 hosts (podman images) while every daemon still ran the old image.
  7. Daemon upgrades then proceeded normally (mgr → mon/crash → osd), finishing at 11/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).
  8. Final state: all daemons on 192.168.210.254:5000/ceph/ceph@sha256:7098775f…, ceph -s healthy (3 mons in quorum, 3 osds up/in, pgs active+clean), consistent ceph versions.

Same-image start (no regression)

ceph orch upgrade start --image 192.168.210.254:5000/ceph/ceph:main-rebase-prepull2

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

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
    • Includes unit test(s)
    • Includes integration test(s)
    • Includes bug reproducer
    • No tests

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch 4 times, most recently from 21b26e4 to ee6c8ae Compare July 20, 2026 09:01
@kginonredhat
kginonredhat requested a review from rkachach July 20, 2026 09:27
@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch 5 times, most recently from 92295d1 to 880a2f2 Compare July 20, 2026 19:16
@kginonredhat

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@kginonredhat

Copy link
Copy Markdown
Contributor Author

jenkins test api

@kginonredhat

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard cephadm

@kginonredhat

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@kginonredhat
kginonredhat marked this pull request as ready for review July 21, 2026 11:52
@kginonredhat
kginonredhat requested review from a team as code owners July 21, 2026 11:52
@FredNass

Copy link
Copy Markdown
Contributor

@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:

  1. No bandwidth safeguard on the seed host. upgrade_image_mirror_max_parallel caps the number of concurrent downloads, but not their throughput. The HTTP server is a bare python3 -m http.server with no rate limiting, and the curl in _load_image_from_url_on_host() has no --limit-rate. With 8 hosts pulling a multi-GB uncompressed tar (even a compressed one, see point 3) at full speed from a single node, the seed's NIC can saturate. If that seed also runs OSDs or a MON (_admin hosts often do), delayed heartbeats could get its OSDs marked down mid-upgrade-start, triggering peering/recovery at the worst possible moment. 🤔

Would you consider adding a per-host rate limit (e.g. --limit-rate driven by an upgrade_image_mirror_max_rate_mbps option) and documenting the benefit of setting it according to the seed host's bandwidth?

  1. This PR removes the simple mode from mgr/cephadm: optionally pre-pull target image on all hosts before upgrade #69358 (parallel direct pull from the registry on all in-scope hosts), leaving the Python HTTP mirror instantiated on a Ceph node as the only pre-distribution mode. I think the two address different infrastructures:
  • Direct pre-pull is simpler and ideal when operators already have a capable local registry (e.g. Harbor), with no need to seed from a Ceph node and the additional risks mentioned in 1.
  • The HTTP mirror shines for air-gapped or remote/fragile registries.

Since upgrade_image_mirror is already opt-in, adding the direct pre-pull back as a sibling opt-in (as in #69358, which was tested and working on a live multi-host cluster) would let operators choose the mode matching their registry situation.

  1. Compressing the image while saving it. Podman load transparently accepts gzip-compressed archives (decompression is handled internally by podman, no external tool needed on the clients), so compressing the image at save time would speed up transfers and reduce both bandwidth usage and the temporary disk space needed on client hosts. Here's what we could use: podman save <image> | python3 -m gzip --fast > tar.gz.

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from 880a2f2 to 9d95fe7 Compare July 21, 2026 15:49
@kginonredhat

Copy link
Copy Markdown
Contributor Author

3. Compressing the image while saving it

regarding #3 Compressing the image while saving it
good idea - implementing and testing it.

regarding having the Direct pre-pull option - i do not see a good use case for this,
hence direct pull will try to pull from the internet usually or from local mirror location , this will always be slower and requires connectivity between all nodes to this registry / mirror / or god forbids to the internet
it is preferred to have one option that eliminates the need to have external access from each node.
In telco environments usually the storage nodes will not have access outside , actually except the Master nodes no other node will have access directly outside.
Moreover, as i m familiar with maintainers they will prefer a less option / less path's - so i want to have this only one resilient option.

regarding the rate limit - indeed good idea , although i doubt someone will use it if no issue's,
but i m working on it to make sure the solution is not affecting other components
thx for the Review and suggestions

@FredNass

Copy link
Copy Markdown
Contributor

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:

  • Nodes can reach a local registry (common in enterprise deployments): direct parallel pre-pull is the natural fit — no tar, no extra disk on the seed, no open port, no NIC saturation risk, ~100 lines.

  • Only one/few nodes have outside access (telco, air-gapped): your HTTP mirror is the right tool, no argument there.

Your current code covers the second case well, but leaves the first with nothing: with upgrade_image_mirror=false there is no pre-pull at all, and the original problem from the tracker (pull time spread across the upgrade, and for MDS counted against CephFS unavailability while the filesystem is already failed) remains unsolved for those operators — unless they enable the seed machinery they don't need.

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 upgrade_pre_pull_images bool reusing your scope/skip/failure-reporting logic, with the mirror as the distribution backend when upgrade_image_mirror is set. The direct variant was implemented, tested and working on a live multi-host cluster in #69358, so the code exists and is small.

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from 9d95fe7 to 03ac49c Compare July 22, 2026 14:07
@kginonredhat

Copy link
Copy Markdown
Contributor Author

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:

  • Nodes can reach a local registry (common in enterprise deployments): direct parallel pre-pull is the natural fit — no tar, no extra disk on the seed, no open port, no NIC saturation risk, ~100 lines.
  • Only one/few nodes have outside access (telco, air-gapped): your HTTP mirror is the right tool, no argument there.

Your current code covers the second case well, but leaves the first with nothing: with upgrade_image_mirror=false there is no pre-pull at all, and the original problem from the tracker (pull time spread across the upgrade, and for MDS counted against CephFS unavailability while the filesystem is already failed) remains unsolved for those operators — unless they enable the seed machinery they don't need.

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 upgrade_pre_pull_images bool reusing your scope/skip/failure-reporting logic, with the mirror as the distribution backend when upgrade_image_mirror is set. The direct variant was implemented, tested and working on a live multi-host cluster in #69358, so the code exists and is small.

well thanks for the explanation
added option to support both
and now testing , after some thinking i would not go with rate limiting at least not before the maintainer will review the code, actually i do not think it will miss heartbeats , as if you tested it with local registry , you probably was not ablke to have rate limit on podman or docker pull
Regards

@FredNass

FredNass commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

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. 👍

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch 2 times, most recently from cf3c635 to d24df58 Compare August 3, 2026 11:40
@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from ccde7bb to 07a0f6f Compare October 29, 2026 08:48
@rkachach rkachach added the wip-rkachach-testing-2 rkachach testing label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

1 similar comment
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from 07a0f6f to 580a903 Compare October 29, 2026 14:13
@kginonredhat

Copy link
Copy Markdown
Contributor Author

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

  1. Serve loop no longer blocked by pre-pull. pre_pull_next_batch() no longer wait_async()s the batch: it starts the batch as a background task on the cephadm event loop (new EventLoopThread.spawn(), a fire-and-forget counterpart to get_result() that never cancels on timeout) and returns immediately. Later serve iterations poll the thread-safe future and apply results, so refresh/deploy/health checks keep running and ceph orch upgrade pause / stop take effect as soon as the running batch returns (its results are then discarded). The metadata first pull got the same treatment: with pre-pull enabled it also runs in the background and is polled, so the long timeout cannot stall serve there either. The mgr-side bound is now asyncio.wait_for(pull_timeout + 60) inside the coroutine instead of a blocking wait_async.
  2. CLI validation keeps the normal timeout. _validate_upgrade_filters() is back to the stock async_timeout_handler('cephadm inspect-image') + default-timeout pull, so a scoped ceph orch upgrade start cannot hang the client; the long pull belongs to serve only. Covered by test_filter_validation_keeps_default_timeout.

Should-fix

  1. Commit split as suggested: (1) timeout plumbing + spawn() + test_cephadm.py mocks, (2) _short_ceph_version()/_announce_target() refactor, (3) the pre-pull feature, (4) docs.
  2. PR description updated (no more mirror/local_http references; documents the background-pull design, the normal CLI validation timeout and the commit split). Replied on the open threads about the method enum, the image_mirror_done migration claim and the serial first pull; the old-design threads (rate limiting, _remote_shell/bash mirror, port 8766) are obsolete — that code no longer exists, pulls go through _run_cephadm pull.
  3. Version parsing change isolated in its own commit with test_short_ceph_version (also documents the new pass-through behavior for already-short version strings).
  4. State mutation moved to the serve thread. The batch coroutine only collects per-host results; mark_host_done() / _fail_upgrade() run in pre_pull_next_batch() when results are harvested, closing the event-loop-thread mutation race.

New/updated tests include test_pre_pull_batch_does_not_block_serve (serve iteration returns while the pull is still running), background first-pull success/failure/timeout paths, pause/stop/replaced-upgrade discard semantics, and the reversed validation-timeout expectation.

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/--timeout 7200 honored, first-host reuse, parallel batch, digest check, mid-upgrade mgr failover survived, Upgrade: Complete!, same-image start completes with no unwanted work.

please review thx

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from 580a903 to f0a0fd0 Compare October 29, 2026 14:23
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@kginonredhat
kginonredhat force-pushed the issue-77270-Optionally-pre-pull-target-image-on-all-hosts-before-upgrade branch from f0a0fd0 to 86e4306 Compare November 4, 2026 11:02
@kginonredhat

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@kginonredhat

Copy link
Copy Markdown
Contributor Author

hi @rkachach — rebased onto latest main (branch is now 86e43068096, no conflicts; PR reports mergeable). The only change beyond the rebase itself: the new upstream CRUSH auto-iterate test (test_upgrade_start_crush_bucket_type_only_auto_iterate) now mocks _validate_upgrade_filters with the 4-tuple return value this PR introduces. Verified locally: full cephadm unit suite green (1861 passed, 1 skipped) and flake8 clean relative to main. please re-review thx

@adk3798 adk3798 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/pybind/mgr/cephadm/image_prepull.py Outdated

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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread src/pybind/mgr/cephadm/image_prepull.py Outdated
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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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', {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread src/pybind/mgr/cephadm/upgrade.py Outdated
target_id, target_version, target_digests = value
first_host = self.image_prepull.first_pull_host
else:
first_host = self.mgr._any_inventory_host()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is first_host doing in the non pre-pull case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@ceph ceph deleted a comment from reduane Nov 6, 2026
@kginonredhat

Copy link
Copy Markdown
Contributor Author

thanks @adk3798! added qa/suites/orch/cephadm/upgrade/2.5-prepull/{defaut,prepull}.yaml — same shape as 2-repo_digest: the prepull variant sets mgr/cephadm/upgrade_prepull_image true before the upgrade runs, defaut keeps it off, so the upgrade suite now exercises the feature both ways (and composes with the existing repo_digest on/off and simple/staggered variants). the 2.5- prefix sorts between 2-repo_digest and 3-upgrade so the config is set before the upgrade starts.

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 |

@FredNass

FredNass commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

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 (mgr/cephadm: optionally pre-pull upgrade image on in-scope hosts) as Co-authored-by or Based-on-patch-by?

Co-authored-by: Frédéric Nass <[email protected]>

@kginonredhat

Copy link
Copy Markdown
Contributor Author

hi @FredNass — done, and thank you for the original work this started from! the feature commit (mgr/cephadm: optionally pre-pull upgrade image on in-scope hosts, now a51d9851c37) carries your trailer:

Co-authored-by: Frédéric Nass <[email protected]>

(message-only change; no code differences — ddb6d01af46)

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

kginonredhat and others added 5 commits November 23, 2026 20:51
_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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants