diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 6e94763..67bc2b5 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -3,5 +3,5 @@ name: py-kube-downscaler description: A Helm chart for deploying py-kube-downscaler type: application -version: 0.2.4 -appVersion: "24.7.1" +version: 0.2.5 +appVersion: "24.8.0" diff --git a/kube_downscaler/scaler.py b/kube_downscaler/scaler.py index 23f4e1f..1e0612f 100644 --- a/kube_downscaler/scaler.py +++ b/kube_downscaler/scaler.py @@ -858,7 +858,7 @@ def autoscale_resource( if downtime_replicas_from_annotation is not None: downtime_replicas = downtime_replicas_from_annotation - if exclude and not original_replicas: + if exclude: logger.debug( f"{resource.kind} {resource.namespace}/{resource.name} was excluded" ) diff --git a/tests/test_scaler.py b/tests/test_scaler.py index ed8f01b..c5d8f93 100644 --- a/tests/test_scaler.py +++ b/tests/test_scaler.py @@ -518,8 +518,7 @@ def get(url, version, **kwargs): ORIGINAL_REPLICAS_ANNOTATION ] - -def test_scaler_upscale_on_exclude(monkeypatch): +def test_scaler_no_upscale_on_exclude(monkeypatch): api = MagicMock() monkeypatch.setattr( "kube_downscaler.scaler.helper.get_kube_api", MagicMock(return_value=api) @@ -575,18 +574,9 @@ def get(url, version, **kwargs): enable_events=False, ) - assert api.patch.call_count == 1 - assert api.patch.call_args[1]["url"] == "/deployments/deploy-1" - assert ( - json.loads(api.patch.call_args[1]["data"])["spec"]["replicas"] - == ORIGINAL_REPLICAS - ) - assert not json.loads(api.patch.call_args[1]["data"])["metadata"]["annotations"][ - ORIGINAL_REPLICAS_ANNOTATION - ] - + assert api.patch.call_count == 0 -def test_scaler_upscale_on_exclude_namespace(monkeypatch): +def test_scaler_no_upscale_on_exclude_namespace(monkeypatch): api = MagicMock() monkeypatch.setattr( "kube_downscaler.scaler.helper.get_kube_api", MagicMock(return_value=api) @@ -641,16 +631,7 @@ def get(url, version, **kwargs): enable_events=False, ) - assert api.patch.call_count == 1 - assert api.patch.call_args[1]["url"] == "/deployments/deploy-1" - assert ( - json.loads(api.patch.call_args[1]["data"])["spec"]["replicas"] - == ORIGINAL_REPLICAS - ) - assert not json.loads(api.patch.call_args[1]["data"])["metadata"]["annotations"][ - ORIGINAL_REPLICAS_ANNOTATION - ] - + assert api.patch.call_count == 0 def test_scaler_always_upscale(monkeypatch): api = MagicMock()