Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from canonical/patch-reboot
Browse files Browse the repository at this point in the history
Drop needs_reboot conditional in `_check_status(...)`
  • Loading branch information
jaimesouza authored Apr 28, 2023
2 parents 9c19e6a + cfa3913 commit 814c7da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,8 @@ def _check_slurmdbd(self, max_attemps=5) -> None:
else:
self.unit.status = BlockedStatus("Cannot start slurmdbd")

def _check_status(self) -> bool:
def _check_status(self) -> bool: # noqa C901
"""Check that we have the things we need."""
if self._slurm_manager.needs_reboot:
self.unit.status = BlockedStatus("Machine needs reboot")
return False

slurm_installed = self._stored.slurm_installed
if not slurm_installed:
self.unit.status = BlockedStatus("Error installing slurm")
Expand Down
15 changes: 1 addition & 14 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,7 @@ def test_is_not_leader(self, _) -> None:
"""Test opposite case of _is_leader method."""
self.assertEqual(self.harness.charm._is_leader(), self.harness.charm.unit.is_leader())

@patch("slurm_ops_manager.SlurmManager.needs_reboot", return_value=True)
def test_check_status_needs_reboot(self, _) -> None:
"""Test that _check_status method works if unit needs reboot."""
res = self.harness.charm._check_status()
self.assertEqual(self.harness.charm.unit.status, BlockedStatus("Machine needs reboot"))
self.assertFalse(
res, msg="_check_status returned value True instead of expected value False."
)

@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
def test_check_status_slurm_not_installed(self, _) -> None:
def test_check_status_slurm_not_installed(self) -> None:
"""Test that _check_status method works if slurm is not installed."""
self.harness.charm._stored.slurm_installed = True
res = self.harness.charm._check_status()
Expand Down

0 comments on commit 814c7da

Please sign in to comment.