Repository navigation
test(tmachine): use K3s ClusterIP, wait for gateway, add failure diagnostics #4258
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6538559
test(k3s): connect tmachine clients directly to ClusterIP
matthewgrossman b14566a
test(conformance): wait for a connected gateway on every installer
matthewgrossman 1767ec0
test(tmachine): centralize gateway diagnostics and trim K3s changes
matthewgrossman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/ansible/roles/openshell_diagnostics/files/collect-k3s.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # No kubeconfig, Secrets, environment dumps, or complete Pod specifications. | ||
| set -u | ||
| umask 077 | ||
| mkdir -p /var/lib/openshell/diagnostics | ||
| output=/var/lib/openshell/diagnostics/k3s.txt | ||
|
|
||
| collect() { | ||
| printf '\n### %s\n' "$1" | ||
| shift | ||
| # Bound both stalled commands and unusually large log streams. | ||
| timeout 10s "$@" 2>&1 | tail -c 262144 | ||
| printf '\ncommand status: %s\n' "${PIPESTATUS[0]}" | ||
| } | ||
|
|
||
| { | ||
| date --utc --iso-8601=seconds | ||
| collect 'K3s service state' systemctl show k3s.service \ | ||
| -p ActiveState -p SubState -p Result -p NRestarts -p ExecMainStatus \ | ||
| -p ExecMainPID -p ActiveEnterTimestamp -p ExecMainStartTimestamp \ | ||
| -p StartLimitIntervalUSec -p StartLimitBurst -p RestartUSec | ||
| collect 'K3s boot journal' journalctl -b --no-pager --lines=500 -u k3s.service | ||
| # kube-proxy may program either iptables backend; dump whichever exist. | ||
| # shellcheck disable=SC2016 # Expanded by the inner shell. | ||
| collect 'Gateway Service routing rules' bash -c ' | ||
| for save in iptables-nft-save iptables-legacy-save; do | ||
| command -v "$save" >/dev/null || continue | ||
| echo "# $save" | ||
| "$save" 2>/dev/null | awk "/openshell\/openshell:grpc/ { print }" | ||
| done' | ||
| collect 'K3s version' /usr/local/bin/k3s --version | ||
| collect 'API readiness' /usr/local/bin/k3s kubectl --request-timeout=5s get --raw=/readyz | ||
| collect 'Nodes' /usr/local/bin/k3s kubectl --request-timeout=5s get nodes -o wide | ||
| collect 'Gateway Pod identity and state' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell get pods \ | ||
| -o 'custom-columns=NAME:.metadata.name,UID:.metadata.uid,PHASE:.status.phase,CONDITIONS:.status.conditions,CONTAINERS:.status.containerStatuses' | ||
| collect 'Gateway Services' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell get services \ | ||
| -o 'custom-columns=NAME:.metadata.name,TYPE:.spec.type,CLUSTERIP:.spec.clusterIP,SELECTOR:.spec.selector,PORTS:.spec.ports' | ||
| collect 'Test client gateway registrations' runuser -u tmachine -- openshell gateway list --output json | ||
| collect 'Test client gateway status' runuser -u tmachine -- openshell status --output json | ||
| collect 'Endpoint readiness' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell get endpointslices \ | ||
| -o 'custom-columns=NAME:.metadata.name,PORTS:.ports,ADDRESSES:.endpoints[*].addresses,CONDITIONS:.endpoints[*].conditions' | ||
| collect 'Gateway events' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell get events --sort-by=.lastTimestamp | ||
| collect 'Gateway current logs' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell logs openshell-0 -c openshell-gateway --tail=300 --timestamps | ||
| collect 'Gateway previous logs' /usr/local/bin/k3s kubectl --request-timeout=5s -n openshell logs openshell-0 -c openshell-gateway --previous --tail=300 --timestamps | ||
| collect 'Memory' free -m | ||
| collect 'Disk' df -h / /var/lib/rancher/k3s | ||
| } | sed -E \ | ||
| -e 's/(Bearer )[A-Za-z0-9._~+\/-]+/\1[REDACTED]/gI' \ | ||
| -e 's/((token|password|secret|authorization)[" ]*[=:][" ]*)[^ ,"]+/\1[REDACTED]/gI' \ | ||
| > "$output" | ||
| cat "$output" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| --- | ||
| # Collect whatever applies to the installed gateway before the VM exits. | ||
| - name: Read OpenShell gateway logs | ||
| become: true | ||
| ansible.builtin.command: | ||
| argv: | ||
| - journalctl | ||
| - --no-pager | ||
| - --lines | ||
| - "500" | ||
| - _SYSTEMD_UNIT=openshell-gateway.service | ||
| - "+" | ||
| - _SYSTEMD_USER_UNIT=openshell-gateway.service | ||
| register: openshell_gateway_logs | ||
| changed_when: false | ||
| failed_when: false | ||
|
|
||
| - name: Show OpenShell gateway logs | ||
| ansible.builtin.debug: | ||
| var: openshell_gateway_logs.stdout_lines | ||
|
|
||
| - name: Check for K3s | ||
| become: true | ||
| ansible.builtin.stat: | ||
| path: /usr/local/bin/k3s | ||
| register: k3s_diagnostics_binary | ||
| failed_when: false | ||
|
|
||
| - name: Preserve K3s diagnostics | ||
| when: k3s_diagnostics_binary.stat.exists | default(false) | ||
| become: true | ||
| block: | ||
| - name: Collect bounded K3s diagnostics | ||
| ansible.builtin.script: collect-k3s.sh | ||
| register: k3s_diagnostics_collection | ||
| changed_when: false | ||
| failed_when: false | ||
|
|
||
| - name: Show K3s diagnostics | ||
| ansible.builtin.debug: | ||
| var: k3s_diagnostics_collection.stdout_lines | ||
|
|
||
| - name: Fetch K3s diagnostics | ||
| ansible.builtin.fetch: | ||
| src: /var/lib/openshell/diagnostics/k3s.txt | ||
| dest: "{{ role_path }}/../../../../artifacts/tmachine-diagnostics/{{ inventory_hostname }}/k3s.txt" | ||
| flat: true | ||
| failed_when: false |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.