Skip to content

Commit e0fae9b

Browse files
authored
Merge pull request #8020 from zalando-incubator/e2e-improvements
add exception handling in toggle-scaledown.py
2 parents a3e7cb6 + 93055a1 commit e0fae9b

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

test/e2e/run_e2e.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ if [ "$e2e" = true ]; then
175175

176176
# TODO(linki): re-introduce the broken DNS record test after ExternalDNS handles it better
177177
#
178-
# # introduce a broken DNS record to mess with ExternalDNS
179-
# cat broken-dns-record.yaml | kubectl apply -f -
178+
# This is still broken in external-dns:v0.14.2-master-40
179+
# InvalidChangeBatch: FATAL problem: DomainLabelEmpty (Domain label is empty) encountered with '_external-dns..teapot-e2e.zalan.do'
180+
#
181+
# introduce a broken DNS record to mess with ExternalDNS
182+
# kubectl apply -f broken-dns-record.yaml
180183

181184
mkdir -p junit_reports
182185
ginkgo -procs=25 -flake-attempts=2 \

test/e2e/toggle-scaledown.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55

66

77
def toggle_scaledown(enabled):
8-
current = json.loads(
9-
subprocess.check_output(
10-
["kubectl", "get", "daemonset", "-o", "json", "-n", "kube-system", "kube-cluster-autoscaler"]
11-
).decode("utf-8")
12-
)
8+
# Try to retrieve daemonset/kube-cluster-autoscalerfrom the e2e cluster
9+
cmd_output = ""
10+
try:
11+
cmd_output = subprocess.check_output(
12+
["kubectl", "get", "daemonset", "-o", "json", "-n", "kube-system", "kube-cluster-autoscaler"],
13+
stderr=subprocess.STDOUT)
14+
except subprocess.CalledProcessError as e:
15+
# This happens when a cluster has been cleaned up, so we should handle it gracefully
16+
if "no such host" in e.output.decode("utf-8"):
17+
print("Failed to reach the API server, is the cluster running?")
18+
raise e
19+
20+
current = json.loads(cmd_output.decode("utf-8"))
1321
for i, container in enumerate(current["spec"]["template"]["spec"]["containers"]):
1422
if container["name"] == "cluster-autoscaler":
1523
command = container["command"]
@@ -46,8 +54,12 @@ def main():
4654
args = parser.parse_args()
4755

4856
enabled = args.action == "enable"
49-
toggle_scaledown(enabled)
50-
57+
58+
try:
59+
toggle_scaledown(enabled)
60+
except subprocess.CalledProcessError as e:
61+
print("Failed to toggle scale-down.")
62+
exit(1)
5163

5264
if __name__ == "__main__":
5365
main()

0 commit comments

Comments
 (0)