-
Notifications
You must be signed in to change notification settings - Fork 316
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
Default namespaces for CRDs that support namespace when enabled #413
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.
Looks good, I like the approach.
Can we remove the special case for serviceintentions now?
I checked out which places default, it's inconsistent. I've made comments where the defaulting doesn't happen.
We might have to keep that around because the validation behavior for Service Intentions are different from the other CRDs (we compare the name and namespace of the destination from the spec which is unique to the CRD) |
80b647c
to
cf2a618
Compare
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.
This is looking good! I haven't tested it out yet. I think we might be able to reduce the code duplication between serviceintentions_webhook
.
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 tested this all out and it works great.
e8ced45
to
7acec7a
Compare
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.
Looking pretty good, Ashwin! I only had one suggestion that I think is holding the approval (to add a test case checking that the DefaultNamespaceFields
implementations won't overwrite a field that's already set); the rest of my comments are pretty minor. Great work!
c.nsMirroring) | ||
c.nsMirroring, | ||
c.consulDestinationNS, | ||
c.nsMirroringPrefix) | ||
require.Equal(t, c.expAllow, response.Allowed) |
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.
Do we need to add an assertion here that the defaulting has worked (maybe check that the DefaultNamespaceFields
method was called on the mock config entry)?
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.
Added a test for the same. It is fairly primitive but let me know if that works of if you'd like something a little more fleshed out.
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.
that works, thanks!
- Add test to verify DefaultingPatches invokes DefaultNamespaceFields. - Add return statement to DefaultNamespaceFields with no behavior.
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.
Looks great! Thanks for addressing the comments.
c.nsMirroring) | ||
c.nsMirroring, | ||
c.consulDestinationNS, | ||
c.nsMirroringPrefix) | ||
require.Equal(t, c.expAllow, response.Allowed) |
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.
that works, thanks!
Changes proposed in this PR:
How to test this PR:
consul-enterprise
with the consul-k8s imageashwinvenkatesh/consul-k8s:default-ns
. Allow namespaces on theconsul
installation.Verify that creating an
ingress-gateway
,terminating-gateway
andservice-router
without namespace fields reconciles just once and does not lead to a reconcile loop.Checklist: