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

ambient: fix nil pointer when pod cache is stale #50878

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

howardjohn
Copy link
Member

I ran into this in an extremely bespoke and unsupported environment,
but I think it could occur in real world. We are looping outside of
GetPodIfAmbient for the pod to show up, but if it fails we panic. We
want to instead get an error.

@howardjohn howardjohn requested a review from a team as a code owner May 7, 2024 00:26
@howardjohn howardjohn added release-notes-none Indicates a PR that does not require release notes. cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch labels May 7, 2024
@istio-testing istio-testing added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 7, 2024
@istio-testing istio-testing added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 7, 2024
@howardjohn howardjohn added the do-not-merge/hold Block automatic merging of a PR. label May 7, 2024
@howardjohn
Copy link
Member Author

I think this logic isn't quite right. will fix it up tomorrow

@istio-testing istio-testing removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 7, 2024
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 7, 2024
@howardjohn howardjohn added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed do-not-merge/hold Block automatic merging of a PR. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 7, 2024
@bleggett
Copy link
Contributor

bleggett commented May 7, 2024

We are looping outside of GetPodIfAmbient for the pod to show up, but if it fails we panic. We want to instead get an error.

I assume you mean PodRedirectionEnabled panics if pod is nil, since we were already returning/getting errors in the other spots?

@howardjohn
Copy link
Member Author

We are looping outside of GetPodIfAmbient for the pod to show up, but if it fails we panic. We want to instead get an error.

I assume you mean PodRedirectionEnabled panics if pod is nil, since we were already returning/getting errors in the other spots?

yes

@@ -82,12 +82,19 @@ func setupHandlers(ctx context.Context, kubeClient kube.Client, dataplane MeshDa
return s
}

// GetPodIfAmbient looks up a pod. It returns:
// * An error if the pod cannot be found
// * nil if the pod is found, but does not have ambient enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just using nil, nil as a sentinel value? Should we just return a different error value for when the pod is found but isn't configured as we expect?

Copy link
Member Author

Choose a reason for hiding this comment

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

I really don't like checking error values personally, its super easy to break accidentally by helpfully wrapping it with more context, etc

I ran into this in an *extremely* bespoke and unsupported environment,
but I think it could occur in real world. We are looping outside of
GetPodIfAmbient for the pod to show up, but if it fails we panic. We
want to instead get an error.
@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 6, 2024
Copy link
Contributor

@bleggett bleggett left a comment

Choose a reason for hiding this comment

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

TY!

@howardjohn
Copy link
Member Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants