Skip to content

Commit d84ea0f

Browse files
committed
handle node failure more better
1 parent 441de0b commit d84ea0f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

deployment/apps/http-echo/statefulset.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ spec:
1414
app: http-echo
1515
spec:
1616
terminationGracePeriodSeconds: 1
17+
tolerations:
18+
- key: "node.kubernetes.io/unreachable"
19+
operator: "Exists"
20+
effect: "NoExecute"
21+
tolerationSeconds: 30
22+
- key: "node.kubernetes.io/not-ready"
23+
operator: "Exists"
24+
effect: "NoExecute"
25+
tolerationSeconds: 30
1726
containers:
1827
- name: echo
1928
image: docker.io/hashicorp/http-echo:1.0

podstatus/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ def watch_pods():
115115
):
116116
pod = event["object"]
117117
pod_name = pod.metadata.name
118-
pod_status = pod.status.phase
119118
pod_index = pod.metadata.labels.get(
120119
"statefulset.kubernetes.io/pod-name", "unknown"
121120
)
122121
pod_node = pod.spec.node_name if pod.spec.node_name else "unknown"
123122

123+
pod_status = pod.status.phase
124+
if pod.metadata.deletion_timestamp is not None:
125+
pod_status = "Terminating"
126+
124127
yield f'data: {{"name": "{pod_name}", "status": "{pod_status}", "index": "{pod_index}", "node": "{pod_node}"}}\n\n'
125128
except Exception as e:
126129
logging.error(f"Error watching pods: {e}")

0 commit comments

Comments
 (0)