Skip to content

Commit

Permalink
[MISC] Don't use planned units for single unit cluster upgrade (#179)
Browse files Browse the repository at this point in the history
* Don't use planned units for single unit cluster upgrade

* Fix linting
  • Loading branch information
dragomirp authored Jul 1, 2024
1 parent b6da549 commit 3f82992
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/charms/data_platform_libs/v0/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def restart(self, event) -> None:

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 17
LIBPATCH = 18

PYDEPS = ["pydantic>=1.10,<2", "poetry-core"]

Expand Down Expand Up @@ -921,7 +921,7 @@ def _on_upgrade_charm(self, event: UpgradeCharmEvent) -> None:
self.charm.unit.status = WaitingStatus("other units upgrading first...")
self.peer_relation.data[self.charm.unit].update({"state": "ready"})

if self.charm.app.planned_units() == 1:
if len(self.app_units) == 1:
# single unit upgrade, emit upgrade_granted event right away
getattr(self.on, "upgrade_granted").emit()

Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ copyright-regexp = "Copyright\\s\\d{4}([-,]\\d{4})*\\s+%(author)s"

[tool.ruff]
line-length = 99
extend-exclude = ["__pycache__", "*.egg_info"]
target-version="py310"
src = ["src", "tests", "lib"]

[tool.ruff.lint]
select = ["E", "W", "F", "C", "N", "D", "I001"]
extend-ignore = [
"D203",
Expand All @@ -58,12 +63,9 @@ extend-ignore = [
"D413",
]
ignore = ["E501", "D107"]
extend-exclude = ["__pycache__", "*.egg_info"]
per-file-ignores = {"tests/*" = ["D100","D101","D102","D103","D104", "E999"]}
target-version="py310"
src = ["src", "tests", "lib"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 12

[tool.pyright]
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ deps =
black
ruff
commands =
ruff --fix {[vars]all_path}
ruff check --fix {[vars]all_path}
black {[vars]all_path}

[testenv:lint]
Expand Down Expand Up @@ -59,7 +59,7 @@ commands =
--ignore-words-list "assertIn"
codespell {[vars]lib_path}

ruff {[vars]all_path}
ruff check {[vars]all_path}
black --check --diff {[vars]all_path}

pyright
Expand Down

0 comments on commit 3f82992

Please sign in to comment.