Skip to content

mgr [progress] [autoscaler]: Fix Autoscaler progress completion + progress module refactors - #65451

Closed
kamoltat wants to merge 4 commits into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-tracker-72857
Closed

kamoltat wants to merge 4 commits into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-tracker-72857

Conversation

@kamoltat

@kamoltat kamoltat commented Sep 9, 2025

Copy link
Copy Markdown
Member

Summary

This PR fixes an issue where the PG Autoscaler progress event could complete incorrectly due to comparing against the wrong target, and includes readability refactors in the progress module along with new test coverage.

Problem

The Autoscaler event’s completion check compared:

pool_data["pg_num"] == pool_data["pg_num_target"]

However, pool_data["pg_num_target"] is not the current scaling target; it reflects the previously computed value (i.e., what the pool was expected to have already reached). As a result, the comparison could erroneously evaluate true and prematurely complete the Autoscaler progress event.

Fix

Use the event’s target recorded at creation time:

pool_data["pg_num"] == ev.pg_num_target

This ensures the event only completes when the pool’s pg_num actually reaches the intended target for this scaling action.

Additional progress-module cleanup

Rename def _refresh() → def _persist() to better reflect behavior.

Rename variables (e.g., pg_stats_active_clean) to more intuitive names for readability.

Refactor global_event_update_progress() for clearer flow and maintainability.

Tests

Add unit tests for the PgAutoscaler event logic in pybind/mgr/progress/test_progress.py to cover correct completion behavior.

Fixes: https://tracker.ceph.com/issues/72857

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

@kamoltat
kamoltat requested a review from a team as a code owner September 9, 2025 11:42
@kamoltat kamoltat self-assigned this Sep 9, 2025
@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-tracker-72857 branch 3 times, most recently from 5b1567f to 9759662 Compare September 11, 2025 13:50
@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check

@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

Comment thread src/pybind/mgr/progress/module.py Resolved

if self._active_clean_num != new_active_clean_num:

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.

part of that commit?

@kamoltat kamoltat Oct 3, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ronen-fr
Yes, basically instead of
if (there are difference in num of active+clean PGs) then (we do some maths)

we change to

we do

if (there are **no** difference in num of active+clean PGs) then (we return to with progress = 1.0) lines below this will do maths.

Comment thread qa/tasks/mgr/test_progress.py Resolved

@ronen-fr ronen-fr 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.

LGTM (some nits)

@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-tracker-72857 branch from 9759662 to 0c15ad4 Compare October 3, 2025 20:25
@kamoltat

kamoltat commented Oct 3, 2025

Copy link
Copy Markdown
Member Author

@ronen-fr Thank you so much for the review!
I made the changes per your comments. Moving this to needs-qa. Let me know if you have other concerns.

@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

@shraddhaag

Copy link
Copy Markdown
Contributor

Hey Junior, I was reviewing the QA run which contains this PR: https://tracker.ceph.com/issues/73380

One of the runs had this error which seems to be coming from the test file modified in this PR:

Failure: Test failure: test_pg_autoscaler_event (tasks.mgr.test_progress.TestProgress)
1 jobs: ['8539064']
suites: ['2-ceph', '3-mgrmodules', '4-units/progress}}', 'base', 'debug/mgr', 'distro/{centos_latest}', 'mem$/{low}', 'mgr_ttl_cache/enable', 'mon_election/connectivity', 'onode-segment$/{1M}', 'rados/mgr/{clusters/{2-node-mgr}', 'random-objectstore$/{bluestore/{alloc$/{avl}', 'random}}}}', 'tasks/{1-install', 'write$/{random/{compr$/{no$/{no}}']

Further logs:

2025-10-07T14:17:11.137 INFO:tasks.cephfs_test_runner:Test PG autoscaler event creation and completion. ... ERROR
2025-10-07T14:17:11.137 INFO:tasks.cephfs_test_runner:
2025-10-07T14:17:11.137 INFO:tasks.cephfs_test_runner:======================================================================
2025-10-07T14:17:11.137 INFO:tasks.cephfs_test_runner:ERROR: test_pg_autoscaler_event (tasks.mgr.test_progress.TestProgress)
2025-10-07T14:17:11.137 INFO:tasks.cephfs_test_runner:Test PG autoscaler event creation and completion.
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/github.com_ceph_ceph-c_81c52ec9eb187a72618a3b2556839de6fb9a48f5/qa/tasks/mgr/test_progress.py", line 551, in test_pg_autoscaler_event
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    ev = self._simulate_pg_autoscaler_event()
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/github.com_ceph_ceph-c_81c52ec9eb187a72618a3b2556839de6fb9a48f5/qa/tasks/mgr/test_progress.py", line 336, in _simulate_pg_autoscaler_event
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    self._setup_pool(size=3, bulk='true', bias=4) # create pool with bias 4 and --bulk flag
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/github.com_ceph_ceph-c_81c52ec9eb187a72618a3b2556839de6fb9a48f5/qa/tasks/mgr/test_progress.py", line 134, in _setup_pool
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    self.mgr_cluster.mon_manager.raw_cluster_cmd(
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/github.com_ceph_ceph-c_81c52ec9eb187a72618a3b2556839de6fb9a48f5/qa/tasks/ceph_manager.py", line 1702, in raw_cluster_cmd
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    return self.run_cluster_cmd(**kwargs).stdout.getvalue()
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/github.com_ceph_ceph-c_81c52ec9eb187a72618a3b2556839de6fb9a48f5/qa/tasks/ceph_manager.py", line 1693, in run_cluster_cmd
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    return self.controller.run(**kwargs)
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_378312a23513074d6ab5d6aab631102b72c77ea7/teuthology/orchestra/remote.py", line 575, in run
2025-10-07T14:17:11.138 INFO:tasks.cephfs_test_runner:    r = self._runner(client=self.ssh, name=self.shortname, **kwargs)
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_378312a23513074d6ab5d6aab631102b72c77ea7/teuthology/orchestra/run.py", line 461, in run
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:    r.wait()
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_378312a23513074d6ab5d6aab631102b72c77ea7/teuthology/orchestra/run.py", line 161, in wait
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:    self._raise_for_status()
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:  File "/home/teuthworker/src/git.ceph.com_teuthology_378312a23513074d6ab5d6aab631102b72c77ea7/teuthology/orchestra/run.py", line 181, in _raise_for_status
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:    raise CommandFailedError(
2025-10-07T14:17:11.139 INFO:tasks.cephfs_test_runner:teuthology.exceptions.CommandFailedError: Command failed on smithi125 with status 22: 'sudo adjust-ulimits ceph-coverage /home/ubuntu/cephtest/archive/coverage timeout 120 ceph --cluster ceph osd pool set progress_data bias 4'

I've requested @SrinivasaBharath to rerun the QA without this PR to be sure. If you could look into the above error that would be great!

target ratio and the effective ratio) is greater.

- **BIAS** is used as a multiplier to manually adjust a pool's PG in accordance
- **BIAS** is the ``pg_autoscale_bias`` and is used as a multiplier to manually adjust a pool's PG in accordance

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.

s/PG/pg_num/

@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-tracker-72857 branch from 835c860 to fb2f3d6 Compare October 17, 2025 19:34
@shraddhaag

Copy link
Copy Markdown
Contributor

Hey @kamoltat, I was reviewing the QA run which contains this PR: https://tracker.ceph.com/issues/73579

One of the runs had this error which seems to be coming from the test file modified in this PR:

Failure: Test failure: test_pg_autoscaler_event (tasks.mgr.test_progress.TestProgress)
1 jobs: ['8576479']
suites: ['2-ceph', '3-mgrmodules', '4-units/progress}}', 'base', 'debug/mgr', 'distro/{ubuntu_latest}', 'mem$/{normal-2}', 'mgr_ttl_cache/enable', 'mon_election/connectivity', 'onode-segment$/{none}', 'rados/mgr/{clusters/{2-node-mgr}', 'random-objectstore$/{bluestore/{alloc$/{stupid}', 'random}}}}', 'tasks/{1-install', 'write$/{random/{compr$/{no$/{no}}']

Here is the corresponding scrape.log link: https://qa-proxy.ceph.com/teuthology/skanta-2025-10-30_09:05:41-rados-wip-bharath2-testing-2025-10-29-2053-distro-default-smithi/scrape.log

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jan 21, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Feb 20, 2026
@kamoltat kamoltat reopened this Apr 20, 2026
@github-actions github-actions Bot removed the stale label Apr 20, 2026
@bluikko

bluikko commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

The "readthedocs" action fails because of Python package changes at RTD. This was fixed for main in #66787 and the action should progress if you are able to rebase your branch onto a fresh main that includes commit 15481e5.

Problem:
We are comparing the wrong value when determining whether the Autoscaler event should be completed or not,
we compared pool_data["pg_num"] == pool_data["pg_num_target"] which will always return true since pool_data["pg_num_target"]
is not actual the target pg we are trying to scale towards, but rather the previous calculated value
that we
are expected to already reached based on previous values.

Solution:
Use the correct value which is comparing pool_data[‘pg_num’] == ev.pg_num_target.

Fixes: https://tracker.ceph.com/issues/72857

Signed-off-by: Kamoltat Sirivadhna <[email protected]>
1. rename def _refresh() to def _persist() for _persist is more true to what the function actually does.
2. rename pg_stats_active_clean Active Py Module objects such that it is more intuitive and more readable.
3. refractor def global_event_update_progres for better readability.

Fixes: https://tracker.ceph.com/issues/72857

Signed-off-by: Kamoltat Sirivadhna <[email protected]>

Conflicts:
	src/pybind/mgr/progress/module.py - Trivial Fix
make it more obvious for the reader that when setting `bias`
in the autoscaler, they need to type in `pg_autoscale_bias`

Fixes: https://tracker.ceph.com/issues/72857

Signed-off-by: Kamoltat Sirivadhna <[email protected]>
@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-tracker-72857 branch from fb2f3d6 to cefe4d3 Compare April 21, 2026 19:08
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jun 20, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Jul 20, 2026
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