Skip to content
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

packages/kata-debug-shell: init #1022

Merged
merged 1 commit into from
Nov 22, 2024
Merged

packages/kata-debug-shell: init #1022

merged 1 commit into from
Nov 22, 2024

Conversation

msanft
Copy link
Contributor

@msanft msanft commented Nov 21, 2024

This adds a little helper script to get a shell into a bare-metal Kata pod VM with a single command.

@msanft msanft requested review from burgerdev and 3u13r November 21, 2024 14:50
@msanft msanft requested a review from katexochen as a code owner November 21, 2024 14:50
@msanft msanft removed the request for review from katexochen November 21, 2024 14:51
@msanft msanft added the no changelog PRs not listed in the release notes label Nov 21, 2024
Comment on lines +17 to +20
container_info=$(k3s ctr c info "$1")

sbx_id=$(echo "$container_info" | jq -r '.Spec.annotations."io.kubernetes.cri.sandbox-id"')
runtime_class_name=$(echo "$container_info" | jq -r '.Snapshotter' | cut -c7-)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this script accepted a pod ID instead of a container ID, you could simplify it to

Suggested change
container_info=$(k3s ctr c info "$1")
sbx_id=$(echo "$container_info" | jq -r '.Spec.annotations."io.kubernetes.cri.sandbox-id"')
runtime_class_name=$(echo "$container_info" | jq -r '.Snapshotter' | cut -c7-)
runtime_class_name=$(k3s crictl pods --id "$1" -o json | jq -r '.items[0].runtimeHandler')

Did you have a particular reason to use the container id?

Copy link
Contributor Author

@msanft msanft Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always found the container ID to be very present in K9s, so I just went with that. I don't think you see the pod UID in K9s at all, without going into the editing window.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see - TIL that container ids are part of the pod status. Should we maybe change the AKS instructions accordingly? Going via kubectl seems more elegant than crictl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As opposed to crictl, this would require one more step to translate container ID into sandbox ID though.

packages/kata-debug-shell.sh Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually (not in this PR), we need to clean up the scripts - I can't say I like how they pile up in packages/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. IMHO, we'd want to move scripts out of there altogether and have it purely as a Nix tree, possibly adding more nesting (as lib.packagesFromDirectoryRecursive can deal with arbitrary nesting).

@msanft msanft requested a review from burgerdev November 22, 2024 08:18
This adds a little helper script to get a shell into a bare-metal Kata pod VM with a single command.
@msanft msanft force-pushed the msanft/kata-debug-shell branch from 723e84a to 9b786ba Compare November 22, 2024 09:09
@msanft msanft merged commit 6f2caf3 into main Nov 22, 2024
11 checks passed
@msanft msanft deleted the msanft/kata-debug-shell branch November 22, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog PRs not listed in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants