Skip to content

Commit

Permalink
Remove unused MAX_COUNT update policy
Browse files Browse the repository at this point in the history
Remove unused MAX_COUNT update policy, that was used only by MaxCount

Signed-off-by: Luca Carrogu <carrogu@amazon.com>
  • Loading branch information
lukeseawalker committed Jan 8, 2024
1 parent 09f1a8f commit f0edf93
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
13 changes: 1 addition & 12 deletions cli/src/pcluster/config/update_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from enum import Enum

from pcluster.config.cluster_config import QueueUpdateStrategy
from pcluster.constants import AWSBATCH, DEFAULT_MAX_COUNT, SLURM
from pcluster.constants import AWSBATCH, SLURM


class UpdatePolicy:
Expand Down Expand Up @@ -511,17 +511,6 @@ def condition_checker_login_nodes_stop_policy(_, patch):
<= patch.target_config["Scheduling"]["AwsBatchQueues"][0]["ComputeResources"][0]["MaxvCpus"],
)

# Checks resize of max_count
UpdatePolicy.MAX_COUNT = UpdatePolicy(
name="MAX_COUNT",
level=1,
fail_reason=lambda change, patch: "Shrinking a queue requires the compute fleet to be stopped first",
action_needed=UpdatePolicy.ACTIONS_NEEDED["pcluster_stop"],
condition_checker=lambda change, patch: not patch.cluster.has_running_capacity()
or (int(change.new_value) if change.new_value is not None else DEFAULT_MAX_COUNT)
>= (int(change.old_value) if change.old_value is not None else DEFAULT_MAX_COUNT),
)

# Update supported only with all compute nodes down or with replacement policy set different from COMPUTE_FLEET_STOP
UpdatePolicy.QUEUE_UPDATE_STRATEGY = UpdatePolicy(
name="QUEUE_UPDATE_STRATEGY",
Expand Down
30 changes: 0 additions & 30 deletions cli/tests/pcluster/config/test_update_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,6 @@
from tests.pcluster.test_utils import dummy_cluster


@pytest.mark.parametrize(
"is_fleet_stopped, old_max, new_max, expected_result",
[
pytest.param(True, 10, 9, True, id="stopped fleet and new_max < old_max"),
pytest.param(False, "10", "9", False, id="running fleet and new_max < old_max"),
pytest.param(True, 10, 11, True, id="stopped fleet new_max > old_max"),
pytest.param(False, 10, 9, False, id="running fleet and new_max < old_max"),
pytest.param(False, 10, 11, True, id="running fleet and new_max > old_max"),
pytest.param(False, None, 0, False, id="running fleet and new_max < DEFAULT_MAX_COUNT"),
pytest.param(False, None, 11, True, id="running fleet and new_max > DEFAULT_MAX_COUNT"),
pytest.param(False, 11, None, False, id="running fleet and DEFAULT_MAX_COUNT < old_max"),
pytest.param(False, 0, None, True, id="running fleet and DEFAULT_MAX_COUNT > old_max"),
],
)
def test_max_count_policy(mocker, is_fleet_stopped, old_max, new_max, expected_result):
cluster = dummy_cluster()
cluster_has_running_capacity_mock = mocker.patch.object(
cluster, "has_running_capacity", return_value=not is_fleet_stopped
)

patch_mock = mocker.MagicMock()
patch_mock.cluster = cluster
change_mock = mocker.MagicMock()
change_mock.new_value = new_max
change_mock.old_value = old_max

assert_that(UpdatePolicy.MAX_COUNT.condition_checker(change_mock, patch_mock)).is_equal_to(expected_result)
cluster_has_running_capacity_mock.assert_called()


@pytest.mark.parametrize(
"is_fleet_stopped, key, path, old_value, new_value, update_strategy, expected_result",
[
Expand Down

0 comments on commit f0edf93

Please sign in to comment.