@@ -115,6 +115,7 @@ assert_file_lacks_pattern() {
115115
116116 assert_file_contains ' name: kubernetes-test-latest-version-e2e-talos-reader' " $kubectl_manifest "
117117 assert_file_contains ' duration: 1h' " $kubectl_manifest "
118+ assert_file_contains ' commonName: kubernetes-test-latest-version-e2e-talos-reader' " $kubectl_manifest "
118119 assert_file_contains ' - os:reader' " $kubectl_manifest "
119120 assert_file_contains ' name: kubernetes-test-latest-version-talos-ca' " $kubectl_manifest "
120121 assert_file_contains ' cozystack-e2e.io/tenant-talos-diagnostics: "test-latest-version"' " $kubectl_manifest "
@@ -138,7 +139,10 @@ assert_file_lacks_pattern() {
138139 assert_file_contains ' -n tenant-test get secret kubernetes-test-latest-version-e2e-talos-reader -o go-template={{index .data "tls.key" | base64decode}}' " $kubectl_calls "
139140 assert_file_contains " --talosconfig $tmp /talosconfig config add kubernetes-test-latest-version --ca $tmp /ca.crt --crt $tmp /client.crt --key $tmp /client.key" " $talosctl_calls "
140141 assert_file_contains " --talosconfig $tmp /talosconfig config context kubernetes-test-latest-version" " $talosctl_calls "
141- [ " $( stat -c ' %a' " $tmp /talosconfig" ) " = 600 ]
142+ case " $( LC_ALL=C ls -ld " $tmp /talosconfig" ) " in
143+ -rw-------* ) ;;
144+ * ) echo " talosconfig permissions are not 0600" >&2 ; return 1 ;;
145+ esac
142146}
143147
144148@test " diagnostics Pod has no API token or Secret volume" {
@@ -155,10 +159,40 @@ assert_file_lacks_pattern() {
155159 assert_file_contains ' readOnlyRootFilesystem: true' " $kubectl_manifest "
156160 assert_file_contains ' drop:' " $kubectl_manifest "
157161 assert_file_contains ' - ALL' " $kubectl_manifest "
158- assert_file_contains ' image: docker.io/library/ubuntu:24.04@sha256:4fbb8e6a8395de5a7550b33509421a2bafbc0aab6c06ba2cef9ebffbc7092d90' " $kubectl_manifest "
162+ assert_file_contains ' image: docker.io/alpine/k8s:1.36.2@sha256:44ef4942e171939b9c665a4a84beb80e2dcdb9a24330d4651cfdfd2e9deecc47' " $kubectl_manifest "
163+ assert_file_contains " 'docker.io/alpine/k8s:1.36.2@sha256:44ef4942e171939b9c665a4a84beb80e2dcdb9a24330d4651cfdfd2e9deecc47'" hack/e2e-install-cozystack.bats
159164 assert_file_lacks_pattern ' secret:|secretName:' " $kubectl_manifest "
160165}
161166
167+ @test " Kubernetes Chainsaw operations leave room for failure diagnostics" {
168+ [ " $( yq ' select(.metadata.name == "kubernetes-latest").spec.steps[0].try[0].script.timeout' hack/e2e-chainsaw/kubernetes-latest/chainsaw-test.yaml) " = 50m ]
169+ [ " $( yq ' select(.metadata.name == "kubernetes-previous").spec.steps[0].try[0].script.timeout' hack/e2e-chainsaw/kubernetes-previous/chainsaw-test.yaml) " = 50m ]
170+ }
171+
172+ @test " orchestrator skips credentials and helper Pod when every VMI lacks an IP" {
173+ . hack/e2e-chainsaw/_lib/run-kubernetes.sh
174+ tmp=$( mktemp -d)
175+ trap ' rm -rf "$tmp"' EXIT
176+ kubectl_calls=" $tmp /kubectl.calls"
177+ kubectl_manifest=" $tmp /manifest.yaml"
178+ kubectl_vmi_json=" $tmp /vmis.json"
179+ talosctl_calls=" $tmp /talosctl.calls"
180+ COZY_REPORT_DIR=" $tmp /report"
181+ COZY_SNAPSHOT_NAME=diagnostic-no-ip
182+ printf ' %s\n' ' {"items":[{"metadata":{"name":"worker-a"},"status":{"interfaces":[{"name":"default"}]}},{"metadata":{"name":"worker-b"},"status":{}}]}' > " $kubectl_vmi_json "
183+
184+ capture_rc=0
185+ cozy_capture_tenant_talos test-latest-version || capture_rc=$?
186+
187+ [ " $capture_rc " -eq 1 ]
188+ assert_file_lacks_pattern ' (^|[[:space:]])apply([[:space:]]|$)' " $kubectl_calls "
189+ assert_file_lacks_pattern ' delete (certificate|secret|pod)|wait (certificate|pod)|exec' " $kubectl_calls "
190+ [ ! -s " $talosctl_calls " ]
191+ assert_file_contains ' default VMI interface has no reported IP address' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-a/capture-error.log"
192+ assert_file_contains ' default VMI interface has no reported IP address' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-b/capture-error.log"
193+ assert_file_contains ' no tenant worker VMI has a reported IP for Talos diagnostics' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/setup-error.log"
194+ }
195+
162196@test " node capture uses the VMI IP for endpoint and node with bounded commands" {
163197 . hack/e2e-chainsaw/_lib/run-kubernetes.sh
164198 tmp=$( mktemp -d)
@@ -209,14 +243,15 @@ assert_file_lacks_pattern() {
209243 timeout_fail_node_ip=10.244.1.93
210244 COZY_REPORT_DIR=" $tmp /report"
211245 COZY_SNAPSHOT_NAME=diagnostic-smoke
212- printf ' %s\n' ' {"items":[{"metadata":{"name":"worker-a"},"status":{"interfaces":[{"name":"default","ipAddress":"10.244.1.93"}]}},{"metadata":{"name":"worker-b"},"status":{"interfaces":[{"name":"default","ipAddress":"10.244.1.94"}]}}]}' > " $kubectl_vmi_json "
246+ printf ' %s\n' ' {"items":[{"metadata":{"name":"worker-no-ip"},"status":{"interfaces":[{"name":"default"}]}},{"metadata":{"name":"worker- a"},"status":{"interfaces":[{"name":"default","ipAddress":"10.244.1.93"}]}},{"metadata":{"name":"worker-b"},"status":{"interfaces":[{"name":"default","ipAddress":"10.244.1.94"}]}}]}' > " $kubectl_vmi_json "
213247 printf ' %s\n' ' #!/bin/sh' > " $tmp /talosctl"
214248 chmod 755 " $tmp /talosctl"
215249 cd " $tmp "
216250
217251 cozy_capture_tenant_talos test-latest-version
218252
219253 [ " $( awk ' / exec kubernetes-test-latest-version-talos-diagnostics / { count++ } END { print count + 0 }' " $kubectl_calls " ) " -eq 4 ]
254+ assert_file_contains ' default VMI interface has no reported IP address' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-no-ip/capture-error.log"
220255 assert_file_contains ' [capture exit code: 124]' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-a/dmesg.log"
221256 assert_file_contains ' [capture exit code: 124]' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-a/kubelet.log"
222257 assert_file_contains ' [capture exit code: 0]' " $COZY_REPORT_DIR /snapshots/$COZY_SNAPSHOT_NAME /tenant-talos/worker-b/dmesg.log"
0 commit comments