Skip to content

Commit 486c18e

Browse files
authored
Merge pull request #17 from djjudas21/valueerror
Fix bug with annotations not being removed
2 parents 7da5505 + a415983 commit 486c18e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kubedownscaler/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def annotate(api, kind: str, name: str, namespace: str, value: str):
1212
'''
1313
Annotate a kube resource with its original number of replicas
1414
'''
15+
# Replace empty string with None, to cause it to be removed
16+
if value == '':
17+
value = None
18+
else:
19+
value = str(value)
20+
1521
body = {"metadata": {"annotations": {
1622
'kubescaledown/originalReplicas': str(value)}}}
1723

@@ -94,6 +100,10 @@ def upscale(api, kind: str, obj, dry_run: bool):
94100
obj.metadata.annotations['kubescaledown/originalReplicas'])
95101
except IndexError:
96102
return
103+
except ValueError:
104+
return
105+
except KeyError:
106+
return
97107

98108
# Remove the annotation, and scale back up
99109
if replicas != original_replicas and not dry_run:

0 commit comments

Comments
 (0)