Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "dying" units from planned units #936

Merged

Conversation

Mehdi-Bendriss
Copy link
Contributor

@Mehdi-Bendriss Mehdi-Bendriss commented May 24, 2023

This PR addresses an issue that happens during a scale-down event, where planned_units includes units with the status marked as dying.
This becomes visible when say the _storage_detaching hook errors based on certain preconditions preventing a unit from immediately disappearing.
This PR essentially filters out those dying units to have an accurate count of live units.

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Idea looks good to me, thanks! A couple of small comments, plus I think we should add a test for this.

The current planned_units() tests only test the Harness/testing version, so perhaps we could add a couple of tests to TestModelBackend that use fake_script(self, 'goal-state', """echo '<json here>'""") to test a couple of cases:

  1. No units.
  2. Two units but none dying, and ensure it returns 2.
  3. Two units with one dying, and ensure it returns 1.

ops/model.py Show resolved Hide resolved
ops/model.py Outdated Show resolved Hide resolved
Mehdi-Bendriss and others added 2 commits May 25, 2023 13:54
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
@benhoyt benhoyt requested a review from jameinel May 25, 2023 22:07
Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@jameinel jameinel left a comment

Choose a reason for hiding this comment

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

Just a thought about a different wording.

ops/model.py Outdated Show resolved Hide resolved
@benhoyt benhoyt merged commit b06697c into canonical:main May 28, 2023
@benhoyt
Copy link
Collaborator

benhoyt commented May 28, 2023

Thanks again @Mehdi-Bendriss!

@Mehdi-Bendriss Mehdi-Bendriss deleted the remove-dying-units-from-planned-units branch May 30, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants