-
Notifications
You must be signed in to change notification settings - Fork 651
rpk: improve rpk debug bundle assumptions in k8s environments #26091
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
Conversation
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.
LGTM!
fmt.Println(errs.Error()) | ||
} | ||
|
||
fmt.Printf("Debug bundle saved to %q\n", f.Name()) | ||
return nil | ||
} | ||
|
||
// adminAddressesUnion returns the union of two slices of adminAddresses. | ||
func adminAddressesUnion(a, b []string) []string { | ||
m := make(map[string]bool) // track unique addresses. |
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.
map[string]struct{}
is technically more efficient here. Though it's much less pleasant to use. This is more of a "the more you know" comment, no change needed IMO.
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.
Thanks! I did the change though 👍
m[v] = true | ||
} | ||
for _, v := range b { | ||
if _, ok := m[v]; !ok { |
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.
if _, ok := m[v]; !ok { | |
if !m[v] { |
The primary benefit of using map[string]bool
(IMO) is that you don't have to use the extended syntax here.
CI test resultstest results on build#65763
test results on build#65823
test results on build#65860
test results on build#65946
|
For Mac users. We won't need this now that we have upgraded to Bazel 8.
We had build tags for the other files already. We previously missed the build tag on this file.
rpk debug bundle works on a best-effort basis. It always tries to return a bundle—even if some steps (like logs or resource collection) fail. Sometimes, is because the system is unhealthy leading to expected errors. Seeing errors doesn't mean the bundle is useless. This change aims to make this clearer for the user.
If --namespace is not provided, fallback to $NAMESPACE, then /var/run/secrets/kubernetes.io/serviceaccount/namespace, and finally default to "redpanda". This avoids hardcoding and better supports various deployment environments.
When collecting a debug bundle from a k8s environment, we now: - Log a warning if admin addresses cannot be retrieved from the k8s API. - Use the union of the profile-defined admin addresses and those returned by the k8s API. - Fall back to 127.0.0.1 if no addresses are available from either source. - Log the final list of admin addresses used. This improves reliability and visibility in environments with incomplete or misconfigured cluster info.
Force Push 1: Addresses PR review suggestions. Force Push 2: rebases with Dev to fix a CI issue. |
We will stop assuming `redpanda` to be the default container name. Instead we are going to fetch the logs of all containers and initContainers in the namespace/pod. Logs will still be stored under logs/
Added d66c6b0 to include the logs of all containers in the pod and stop assuming |
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.
LGTM sans the loop/closure scoping question.
cb := func(ctx context.Context) ([]byte, error) { | ||
return podsInterface.GetLogs(p.Name, opts).Do(ctx).Raw() | ||
} | ||
grp.Go(func() error { return requestAndSave(ctx, ps, fmt.Sprintf("logs/%v-%v.txt", p.Name, c.Name), cb) }) |
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.
I think this is fine as of go 1.23 but the reference to p
and c
in a closure from another goroutine inside a doublely nested loop has all of my internal go alarms ringing.
Just to check have you tested this on a cluster with multiple containers and Pods and observed that the logs are all named correctly?
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.
/backport v25.1.x |
/backport v24.3.x |
/backport v24.2.x |
Failed to create a backport PR to v24.2.x branch. I tried:
|
Fixes UX-114
This PR:
Misc. changes
Backports Required
Release Notes
Improvements