Skip to content

Control PG autoscaler during upgrades with pg_autoscale_during_upgrade - #67694

Merged
rkachach merged 1 commit into
ceph:mainfrom
ashjosh1git:ceph-tracker-69477-pgscalar
May 14, 2026
Merged

rkachach merged 1 commit into
ceph:mainfrom
ashjosh1git:ceph-tracker-69477-pgscalar

Conversation

@ashjosh1git

@ashjosh1git ashjosh1git commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor

The requirement is to be able to control the PG autoscale for OSDs during upgrades with an opt-in option made available with cephadm mgr. More details are in the tracker issue 69477.

This code introduces the following functionality. The prior setting for autoscale is reverted back to original if it was changed due to pg_autoscale_during_upgrade value. The following flags are evaluated for decision making before the upgrade process:

  • Prior setting for Autoscale ON based on osd pool get noautoscale (False=>Autoscale ON, default:False)
  • User opt-in with mgr/cephadm/pg_autoscale_during_upgrade (true=>autoscale ON during upgrade, default:False)
Case Autoscale ON prior to upgrade (OSD autoscale allowed) Autoscale ON opted-in by user Autoscale ON during upgrades Autoscale ON after upgrade (OSD autoscale allowed)
1 No False (default) No No
2 No True Yes No
3 Yes (default) False (default) No Yes
4 Yes (default) True Yes Yes

It must be noted that the pg_autoscale_during_upgrade option would be available after mgr gets upgraded first as a part of staged upgrades.

The case 3 is most probable scenario. The unit tests for the same are below:

[ceph: root@ceph-node-0 /]# ceph osd pool get noautoscale
noautoscale is off
[ceph: root@ceph-node-0 /]# 
==> autoscale in ON prior to upgrade
pg_autoscale_during_upgrade won’t be available till the time mgr gets upgrades first.

[ceph: root@ceph-node-0 /]# ceph config get mgr mgr/cephadm/pg_autoscale_during_upgrade
Error ENOENT: unrecognized key 'mgr/cephadm/pg_autoscale_during_upgrade'
[ceph: root@ceph-node-0 /]#


Upgrade mgr

[ceph: root@ceph-node-0 /]# ceph orch upgrade start quay.io/ashjoshi/ceph:upgradetesting --daemon-types mgr
Initiating upgrade to quay.io/ashjoshi/ceph:upgradetesting
[ceph: root@ceph-node-0 /]# ceph orch upgrade status
{
    "in_progress": true,
    "target_image": "quay.io/ashjoshi/ceph@sha256:6a037b9cdc937da29bfd3c9965c9b2f9ca4602adecf3348e5d8f2dcb7e62b0a5",
    "services_complete": [
        "mgr"
    ],
    "which": "Upgrading daemons of type(s) mgr",
    "progress": "2/2 daemons upgraded",
    "message": "",
    "is_paused": false
}
[ceph: root@ceph-node-0 /]# ceph orch upgrade status
There are no upgrades in progress currently.
[ceph: root@ceph-node-0 /]#
Now pg_autoscale_during_upgrade is false () that means it would disable the autoscaling 
during the upgrade and then restore it to original config.

[ceph: root@ceph-node-0 /]# ceph config get mgr mgr/cephadm/pg_autoscale_during_upgrade
false <<<<<<
[ceph: root@ceph-node-0 /]#

Upgrade osd

[ceph: root@ceph-node-0 /]# ceph orch upgrade start quay.io/ashjoshi/ceph:upgradetesting --daemon-types osd
Initiating upgrade to quay.io/ashjoshi/ceph:upgradetesting
mgr logs show the previous found configs, set and restore of the PG autoscaler. 

[root@ceph-node-0 263f432e-193b-11f1-a0a4-5254004652b9]# cat ceph-mgr.ceph-node-0.ptnlzz.log |  grep autoscal | grep "Upgrade"
2026-03-06T10:38:03.953+0000 7f3db8a69640  0 [cephadm INFO cephadm.upgrade] Upgrade: PG autoscaling prior=True, mgr/cephadm/pg_autoscale_during_upgrade=False, autoscaling during upgrade=False
2026-03-06T10:38:03.953+0000 7f3db8a69640  0 log_channel(cephadm) log [INF] : Upgrade: PG autoscaling prior=True, mgr/cephadm/pg_autoscale_during_upgrade=False, autoscaling during upgrade=False
2026-03-06T10:38:05.025+0000 7f3db8a69640  0 [cephadm INFO cephadm.upgrade] Upgrade: Set noautoscale for OSD upgrade
2026-03-06T10:38:05.025+0000 7f3db8a69640  0 log_channel(cephadm) log [INF] : Upgrade: Set noautoscale for OSD upgrade
2026-03-06T10:39:29.089+0000 7f3dc02b8640  0 [cephadm INFO cephadm.upgrade] Upgrade: Restored PG autoscaling to on
2026-03-06T10:39:29.089+0000 7f3dc02b8640  0 log_channel(cephadm) log [INF] : Upgrade: Restored PG autoscaling to on

Upgrade complete

[ceph: root@ceph-node-0 /]# ceph orch upgrade status
There are no upgrades in progress currently.

Previous config for PG autoscale is restored as expected ==> autoscale in ON as it was prior to upgrade

[ceph: root@ceph-node-0 /]# ceph osd pool get noautoscale
noautoscale is off
[ceph: root@ceph-node-0 /]#

Fixes: https://tracker.ceph.com/issues/69477
Signed-off-by: Ashwin M. Joshi [email protected]

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@ashjosh1git
ashjosh1git requested review from a team as code owners March 6, 2026 11:57
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

14 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@rkachach

rkachach commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Hi @ashjosh1git plz have a look to https://github.com/ceph/ceph/blob/main/SubmittingPatches.rst#commit-title for commits msg formating.

@anthonyeleven

Copy link
Copy Markdown
Contributor

Implementation is the most sincere form of flattery :)

“Autoscaler” in the title, please. Spelling.

@ashjosh1git
ashjosh1git force-pushed the ceph-tracker-69477-pgscalar branch from 8d91f75 to 6b6a1f5 Compare March 9, 2026 05:31
@ashjosh1git ashjosh1git changed the title Control PG autoscalar during upgrades with pg_autoscale_during_upgrade Control PG autoscaler during upgrades with pg_autoscale_during_upgrade Mar 9, 2026
@rkachach
rkachach requested a review from Copilot March 12, 2026 11:00

Copilot AI 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.

Pull request overview

This PR adds a new pg_autoscale_during_upgrade option to cephadm that controls whether PG autoscaling remains active during OSD upgrades. By default (false), cephadm disables PG autoscaling (sets noautoscale) before upgrading OSDs and restores the prior setting afterward. Setting the option to true opts in to keeping autoscaling enabled during upgrades.

Changes:

  • Adds pg_autoscale_during_upgrade boolean option to the cephadm module, with logic to disable/restore PG autoscaling around OSD upgrades based on the option and prior cluster state.
  • Introduces helper methods to determine if an upgrade includes OSDs and to set/unset the noautoscale flag, with retry logic for transient failures.
  • Adds comprehensive unit tests for the decision table and documentation for the new option.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/pybind/mgr/cephadm/upgrade.py Adds noautoscale_set/prior_autoscale to UpgradeState, new methods to detect OSD inclusion and set/unset noautoscale, and hooks in upgrade start/stop/fail/complete paths.
src/pybind/mgr/cephadm/module.py Registers the new pg_autoscale_during_upgrade module option (bool, default False).
src/pybind/mgr/cephadm/tests/test_upgrade.py Adds parametrized tests for the autoscaling decision table, OSD-exclusion logic, and revert-after-upgrade behavior.
doc/cephadm/upgrade.rst Documents the new pg_autoscale_during_upgrade option in the upgrade guide.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/pybind/mgr/cephadm/upgrade.py Resolved
Comment thread src/pybind/mgr/cephadm/upgrade.py Resolved
Comment thread src/pybind/mgr/cephadm/upgrade.py Resolved
Comment thread doc/cephadm/upgrade.rst Resolved
@rkachach

Copy link
Copy Markdown
Contributor

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok to test" to allow the Jenkins jobs to run.

@ashjosh1git

ashjosh1git commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@ashjosh1git several upgrade test-cases are failing, plz double check:

https://pulpito.ceph.com/rkachach-2026-03-15_14:11:14-orch:cephadm-wip-rkachach-testing-2026-03-14-1056-distro-default-trial/

Thanks @rkachach, the failures are not related to the PR. There were mostly due to a recent addition of a new objectstore flag to some ceph-volume commands as I understand. These failures may happen in any upgrade runs at this moment. Thanks.

@ashjosh1git
ashjosh1git force-pushed the ceph-tracker-69477-pgscalar branch from 6b6a1f5 to 40770e0 Compare March 18, 2026 17:40
Comment thread doc/cephadm/upgrade.rst Resolved
@ashjosh1git

Copy link
Copy Markdown
Contributor Author

jenkins test make check

1 similar comment
@ShwetaBhosale1

Copy link
Copy Markdown
Contributor

jenkins test make check

@kamoltat

kamoltat commented Apr 14, 2026 •

Copy link
Copy Markdown
Member

I would like to note that sometimes checking if "noautoscale" flag is "not set" alone is not enough to justify that autoscaler is "on" for each pool. The pools has it's individual pg_autoscale_mode value | on | off | warn which is a pool level configurable value. "noautoscale" flag is a global value that masks the individual pg_autosacle_mode value of each pool. You set "noautoscale" means you putting the mask on which yes the mgr autoscaler module will not scale any pool, however, individual setting of pg_autosacle_mode of each pool will remain the same.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@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

…pgrade

Fixes: https://tracker.ceph.com/issues/69477
Signed-off-by: Ashwin M. Joshi <[email protected]>

 Conflicts:
	src/pybind/mgr/cephadm/tests/test_upgrade.py
	src/pybind/mgr/cephadm/upgrade.py
@rkachach

Copy link
Copy Markdown
Contributor

ok-to-test

@rkachach

Copy link
Copy Markdown
Contributor

@rkachach
rkachach merged commit 5a0c2ae into ceph:main May 14, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/25880473308

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.

10 participants