Skip to content

Commit 273e61f

Browse files
committed
print exception in logs
1 parent 8cf1011 commit 273e61f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

files/aautoscaler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __start__(self, namespace:str, deploy:dict, currentTime:datetime):
4545
startReplicas = 1
4646
startReplicasAnnotation = 'another-autoscaler/start-replicas'
4747
if startReplicasAnnotation in deployAnnotations:
48-
self.logs.debug({'message': 'Replicas defined by the user for start.', 'namespace': namespace, 'deployment': deployName, 'startReplicas': deployAnnotations[startReplicasAnnotation]})
48+
self.logs.debug({'message': 'Number of replicas.', 'namespace': namespace, 'deployment': deployName, 'startReplicas': deployAnnotations[startReplicasAnnotation]})
4949
startReplicas = int(deployAnnotations[startReplicasAnnotation])
5050

5151
if deployReplicas != startReplicas:
@@ -72,7 +72,7 @@ def __stop__(self, namespace:str, deploy:dict, currentTime:datetime):
7272
stopReplicas = 0
7373
stopReplicasAnnotation = 'another-autoscaler/stop-replicas'
7474
if stopReplicasAnnotation in deployAnnotations:
75-
self.logs.debug({'message': 'Replicas defined by the user for stop.', 'namespace': namespace, 'deployment': deployName, 'stopReplicas': deployAnnotations[stopReplicasAnnotation]})
75+
self.logs.debug({'message': 'Number of replicas.', 'namespace': namespace, 'deployment': deployName, 'stopReplicas': deployAnnotations[stopReplicasAnnotation]})
7676
stopReplicas = int(deployAnnotations[stopReplicasAnnotation])
7777

7878
if deployReplicas != stopReplicas:

files/k8s.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def getNamespaces(self) -> list:
3636
response = self.CoreV1Api.list_namespace()
3737
return response.items
3838
except ApiException as e:
39+
print(e)
3940
self.logs.error({'message': 'Exception when calling CoreV1Api.list_namespace'})
4041
return []
4142

@@ -51,6 +52,7 @@ def getDeployments(self, namespace:str, labelSelector:str=False) -> list:
5152
response = self.AppsV1Api.list_namespaced_deployment(namespace=namespace)
5253
return response.items
5354
except ApiException as e:
55+
print(e)
5456
self.logs.error({'message': 'Exception when calling AppsV1Api.list_namespaced_deployment'})
5557
return []
5658

@@ -61,6 +63,7 @@ def getDeployment(self, namespace:str, deploymentName:str):
6163
try:
6264
return self.AppsV1Api.read_namespaced_deployment(namespace=namespace, name=deploymentName)
6365
except ApiException as e:
66+
print(e)
6467
self.logs.error({'message': 'Exception when calling AppsV1Api.read_namespaced_deployment'})
6568
return []
6669

@@ -73,6 +76,7 @@ def getPods(self, namespace:str, labelSelector:str, limit:int=1) -> list:
7376
response = self.CoreV1Api.list_namespaced_pod(namespace=namespace, label_selector=labelSelector, limit=limit)
7477
return response.items
7578
except ApiException as e:
79+
print(e)
7680
self.logs.error({'message': 'Exception when calling CoreV1Api.list_namespaced_pod'})
7781
return []
7882

@@ -116,6 +120,7 @@ def setReplicas(self, namespace:str, deploymentName:str, replicas:int) -> bool:
116120
self.AppsV1Api.replace_namespaced_deployment_scale(namespace=namespace, name=deploymentName, body=currentScale)
117121
return True
118122
except ApiException as e:
123+
print(e)
119124
self.logs.error({'message': 'Exception when calling AppsV1Api.read_namespaced_deployment_scale'})
120125
return False
121126

@@ -126,6 +131,7 @@ def getReplicas(self, namespace:str, deploymentName:str):
126131
try:
127132
return self.AppsV1Api.read_namespaced_deployment_scale(namespace=namespace, name=deploymentName)
128133
except ApiException as e:
134+
print(e)
129135
self.logs.error({'message': 'Exception when calling AppsV1Api.read_namespaced_deployment_scale'})
130136
return False
131137

@@ -142,6 +148,7 @@ def rolloutDeployment(self, namespace:str, deploymentName:str) -> bool:
142148
self.AppsV1Api.replace_namespaced_deployment(namespace=namespace, name=deploymentName, body=deploymentManifest)
143149
return True
144150
except ApiException as e:
151+
print(e)
145152
self.logs.error({'message': 'Exception when calling AppsV1Api.replace_namespaced_deployment'})
146153
return False
147154

0 commit comments

Comments
 (0)