We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In https://github.com/pelotech/nidhogg/blob/main/pkg/nidhogg/handler.go#L256, there's a bug in the pod matching loop where the address of the loop variable is being appended to the matchingPods slice. This results in all elements of matchingPods pointing to the same memory location (the last processed pod), rather than distinct pods.
matchingPods
Possible fix is to copy the pod to a new variable before appending it to the list:
matchingPods := make([]*corev1.Pod, 0) for _, pod := range pods.Items { for _, owner := range pod.OwnerReferences { if owner.Name == ds.Name && pod.Spec.NodeName == nodeName { p := pod matchingPods = append(matchingPods, &p) } } }
See: https://stackoverflow.com/questions/45967305/copying-the-address-of-a-loop-variable-in-go
The text was updated successfully, but these errors were encountered:
scoquelin
Successfully merging a pull request may close this issue.
In https://github.com/pelotech/nidhogg/blob/main/pkg/nidhogg/handler.go#L256, there's a bug in the pod matching loop where the address of the loop variable is being appended to the
matchingPods
slice. This results in all elements ofmatchingPods
pointing to the same memory location (the last processed pod), rather than distinct pods.Possible fix is to copy the pod to a new variable before appending it to the list:
See: https://stackoverflow.com/questions/45967305/copying-the-address-of-a-loop-variable-in-go
The text was updated successfully, but these errors were encountered: