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 #9 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 May 2, 2023
2 parents d8c4bd6 + 0981aff commit e307f69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__/
*.py[cod]
.idea
.vscode/
version
14 changes: 5 additions & 9 deletions src/charm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python3
# Copyright 2020 Omnivector Solutions, LLC.
# See LICENSE file for licensing details.

"""SlurmrestdCharm."""

import logging
from pathlib import Path

Expand All @@ -8,11 +12,7 @@
from ops.charm import CharmBase
from ops.framework import StoredState
from ops.main import main
from ops.model import (
ActiveStatus,
BlockedStatus,
WaitingStatus,
)
from ops.model import ActiveStatus, BlockedStatus, WaitingStatus
from slurm_ops_manager import SlurmManager

logger = logging.getLogger()
Expand Down Expand Up @@ -134,10 +134,6 @@ def _on_configure_jwt_rsa(self, event):
self._slurm_manager.configure_jwt_rsa(jwt_rsa)

def _check_status(self) -> bool:
if self._slurm_manager.needs_reboot:
self.unit.status = BlockedStatus("Machine needs reboot")
return False

if not self._stored.slurm_installed:
self.unit.status = BlockedStatus("Error installing slurmrestd")
return False
Expand Down
20 changes: 0 additions & 20 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def test_config_available_fail(self, defer):
"interface_slurmrestd.SlurmrestdRequires.get_stored_slurm_config",
return_value={"cluster_name": "test"},
)
@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
@patch(
"interface_slurmrestd.SlurmrestdRequires.is_joined",
new_callable=PropertyMock(return_value=True),
Expand All @@ -69,10 +65,6 @@ def test_install_fail(self, defer, *_):
self.assertFalse(self.harness.charm._stored.slurm_installed)
defer.assert_called()

@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
@patch(
"interface_slurmrestd.SlurmrestdRequires.is_joined",
new_callable=PropertyMock(return_value=True),
Expand Down Expand Up @@ -125,10 +117,6 @@ def test_restart_slurmrestd_fail(self, defer):
defer.assert_called()

@patch("slurm_ops_manager.SlurmManager.restart_slurm_component", lambda _: True)
@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
@patch(
"interface_slurmrestd.SlurmrestdRequires.is_joined",
new_callable=PropertyMock(return_value=True),
Expand All @@ -154,10 +142,6 @@ def test_update_status_fail(self):
self.harness.charm.unit.status, BlockedStatus("Error installing slurmrestd")
)

@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
@patch(
"interface_slurmrestd.SlurmrestdRequires.is_joined",
new_callable=PropertyMock(return_value=True),
Expand All @@ -179,10 +163,6 @@ def test_upgrade_fail(self, *_):
)

@patch("pathlib.Path.read_text", return_value="v1.0.0")
@patch(
"slurm_ops_manager.SlurmManager.needs_reboot",
new_callable=PropertyMock(return_value=False),
)
@patch(
"interface_slurmrestd.SlurmrestdRequires.is_joined",
new_callable=PropertyMock(return_value=True),
Expand Down

0 comments on commit e307f69

Please sign in to comment.