Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support annotations errors #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Define exceptions
margori committed Apr 20, 2022

Verified

This commit was signed with the committer’s verified signature.
laozc Zhongcheng Lao
commit 429411f3927974bb8efa948b5092de6f9a55be0f
12 changes: 6 additions & 6 deletions files/aautoscaler.py
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ def __start__(self, namespace: str, deploy: dict, currentTime: datetime):
try:
if not croniter.match(startTime, currentTime):
return
except:
except Exception as e:
self.logs.error(
{'message': 'Error in start-time annotation', 'namespace': namespace, 'deployment': deployName})
return
@@ -66,7 +66,7 @@ def __start__(self, namespace: str, deploy: dict, currentTime: datetime):
try:
startReplicas = int(
deployAnnotations[startReplicasAnnotation])
except:
except Exception as e:
startReplicas = 1

if deployReplicas == startReplicas:
@@ -97,7 +97,7 @@ def __stop__(self, namespace: str, deploy: dict, currentTime: datetime):
try:
if not croniter.match(stopTime, currentTime):
return
except:
except Exception as e:
self.logs.error(
{'message': 'Error in stop-time annotation', 'namespace': namespace, 'deployment': deployName})
return
@@ -117,7 +117,7 @@ def __stop__(self, namespace: str, deploy: dict, currentTime: datetime):
try:
stopReplicas = int(
deployAnnotations[stopReplicasAnnotation])
except:
except Exception as e:
stopReplicas = 0

if deployReplicas == stopReplicas:
@@ -148,7 +148,7 @@ def __restart__(self, namespace: str, deploy: dict, currentTime: datetime):

if not croniter.match(restartTime, currentTime):
return
except:
except Exception as e:
self.logs.error(
{'message': 'Error in restart-time annotation', 'namespace': namespace, 'deployment': deployName})
return
@@ -160,7 +160,7 @@ def __restart__(self, namespace: str, deploy: dict, currentTime: datetime):
try:
restartedAt = parser.parse(
deploy.spec.template.metadata.annotations['kubectl.kubernetes.io/restartedAt'])
except:
except Exception as e:
restartedAt = currentTime - timedelta(days=1)

if ((currentTime - restartedAt).total_seconds() / 60.0) <= 1: