Skip to content

Commit

Permalink
Merge pull request #87 from runningman84/patch-1
Browse files Browse the repository at this point in the history
Fix KEDA ScaledObject KeyError
  • Loading branch information
samuel-esp authored Aug 22, 2024
2 parents 2533c9b + 9f4913d commit 8def356
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kube_downscaler/scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,10 @@ def scale_down(
f"Scaling down {resource.kind} {resource.namespace}/{resource.name} from {replicas} to {target_replicas} replicas (uptime: {uptime}, downtime: {downtime})"
)
elif resource.kind == "ScaledObject":
if resource.annotations[ScaledObject.keda_pause_annotation] is not None:
paused_replicas = resource.annotations[ScaledObject.keda_pause_annotation]
resource.annotations[ScaledObject.last_keda_pause_annotation_if_present] = paused_replicas
if ScaledObject.keda_pause_annotation in resource.annotations:
if resource.annotations[ScaledObject.keda_pause_annotation] is not None:
paused_replicas = resource.annotations[ScaledObject.keda_pause_annotation]
resource.annotations[ScaledObject.last_keda_pause_annotation_if_present] = paused_replicas
resource.annotations[ScaledObject.keda_pause_annotation] = "0"
logger.info(
f"Pausing {resource.kind} {resource.namespace}/{resource.name} (uptime: {uptime}, downtime: {downtime})"
Expand Down

0 comments on commit 8def356

Please sign in to comment.