-
Notifications
You must be signed in to change notification settings - Fork 28
[EXPERIMENT] Instrument component-tests for pod restarts and node resource pressure #953
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -182,3 +182,22 @@ jobs: | |||||||||
| echo "-----------------------------------------" | ||||||||||
| echo "Storage logs" | ||||||||||
| kubectl logs $(kubectl get pods -n kubescape -o name | grep storage) -n kubescape | ||||||||||
| - name: Diagnose pod restarts and node resource pressure | ||||||||||
| if: always() | ||||||||||
| run: | | ||||||||||
| echo "Node describe (allocatable/capacity vs requests)" | ||||||||||
| kubectl describe nodes | ||||||||||
| echo "-----------------------------------------" | ||||||||||
| echo "Pods across all namespaces, with restart counts" | ||||||||||
| kubectl get pods -A -o wide | ||||||||||
| echo "-----------------------------------------" | ||||||||||
| echo "Pods with non-zero restarts (detail)" | ||||||||||
| for p in $(kubectl get pods -A --no-headers -o custom-columns=":metadata.namespace,:metadata.name,:status.containerStatuses[0].restartCount" | awk '$3!="" && $3!="<none>" && $3+0>0 {print $1"/"$2}'); do | ||||||||||
| ns=$(echo "$p" | cut -d/ -f1) | ||||||||||
| name=$(echo "$p" | cut -d/ -f2) | ||||||||||
| echo "=== $ns/$name ===" | ||||||||||
| kubectl describe pod "$name" -n "$ns" | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 47721 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- workflow excerpt ---'
sed -n '175,210p' .github/workflows/component-tests.yaml
printf '%s\n' '--- workflow shell-related settings ---'
rg -n -C 3 'shell:|kubectl describe|kubectl get pods|kubectl get events|restartCount|diagnostic|failure' .github/workflows/component-tests.yaml
printf '%s\n' '--- workflow structure ---'
sed -n '1,35p' .github/workflows/component-tests.yamlRepository: kubescape/node-agent Length of output: 4746 Continue diagnostics when a pod disappears. Because this job does not override Proposed best-effort handling- kubectl describe pod "$name" -n "$ns"
+ if ! kubectl describe pod "$name" -n "$ns"; then
+ echo "Unable to describe ${ns}/${name}; continuing diagnostics"
+ fi📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.29.0)[warning] 1-204: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) [warning] 69-204: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) 🤖 Prompt for AI Agents |
||||||||||
| done | ||||||||||
| echo "-----------------------------------------" | ||||||||||
| echo "Cluster events, sorted by time (liveness/readiness probe failures, OOMKilled, etc.)" | ||||||||||
| kubectl get events -A --sort-by=.lastTimestamp | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge kubescape/node-agent /tmp/coderabbit-repo-knowledge/kubescape-node-agent-0fec8791/architectureLength of output: 47122
🏁 Script executed:
Repository: kubescape/node-agent
Length of output: 4576
🌐 Web query:
site:docs.github.com GitHub Actions default shell bash --noprofile --norc -eo pipefail run step💡 Result:
When you use
shell: bashin a GitHub Actionsrunstep on a Linux runner, GitHub Actions automatically executes the command using the following arguments:bash --noprofile --norc -e -o pipefail {0}. Key components of this behavior include: --noprofile: Prevents bash from loading configuration files like /etc/profile or ~/.profile. --norc: Prevents bash from loading ~/.bashrc. -e: Ensures the shell exits immediately if any command in the script returns a non-zero exit status. -o pipefail: Ensures that if any command in a pipeline fails, the entire pipeline is considered failed (the exit status of the pipeline will be the exit status of the last command to exit with a non-zero status). {0}: This is a placeholder for the actual script content you provide in the workflow file. This default configuration ensures that your workflow steps run in a clean, predictable environment that is not affected by user-specific shell configurations and that failures in pipelines or commands are correctly caught. Note that whilebashis the default for most Linux-based runners, it is not the default shell inside containers, where the default issh[1]. You can override these defaults at the workflow or job level using thedefaults.runkey [2][3].Citations:
Inspect all regular and init-container statuses.
Line 195 checks only
.status.containerStatuses[0].restartCount. A restarted sidecar or init container can be omitted when the first regular container has zero restarts. Enumerate all entries incontainerStatusesandinitContainerStatuses, then describe the pod when anyrestartCountis greater than zero.The step uses GitHub Actions' default
bash -e -o pipefailmode. Guard the per-podkubectl describecommand because a deleted pod can stop the loop before cluster events are collected.Proposed selection change
🧰 Tools
🪛 zizmor (1.29.0)
[warning] 1-204: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 69-204: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents