-
Notifications
You must be signed in to change notification settings - Fork 186
feat: namespace metadata sync on creation #1378 #1379
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
✅ Deploy Preview for capsule-documentation canceled.
|
Hey until the new implementation is done i am happy to consider this one, could you adsd one e2e test? |
f900474
to
8c03103
Compare
Hello @oliverbaehler At first look, I thought this change would be a quick 5-minute adventure. But soon I have realized that all mutation changes need to be handled in a single place. This PR will guarantee consistent namespace metadata on creation/reconcile. I have also added e2e for both webhook and controller namespace reconcile. Additionally, I encountered issues with the Harpoon image: Please take a look when you'll have time. |
/retest |
Have no failed test in trace-e2e on my ubuntu workstation. |
You can |
13815a9
to
16ba36f
Compare
@Svarrogh1337 @oliverbaehler , apologies, just found time for this. On my ubuntu workstation everything is ok even with harpoon: Could you confirm? |
pkg/webhook/namespace/patch.go
Outdated
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.
Why does the logic have to be in one handler?
The patch.go
is a validating handler. Therefor it should not be combined with your change. You have done the right thing with registering a new route to generalize the mutation of namespace. However i would rename the current ownerreference folder into namespace-mutating or whatever and then keep the logic for patching in a dedicated handler (as is) and add a new handler, which just handles the nodeSelector.
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.
Got your point about patch.go
.
There is a huge logic to detect namespace ownership in onCreate, I just wanted to do it Once in one place.
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.
@oliverbaehler , could you take a look at new PR. Is it what you wanted?
Yeah there was just a feagure merged which adds the subpackages for namespace mutations and validations. You may add your logic now as dedicated handler in the namespcae mutation package. Should be much simpler now |
c24ac88
to
f5d264b
Compare
@oliverbaehler , I have made changes considering last mutation feature, could you take a look? |
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.
You may delete this one, as yours achieves the same thing
// sync namespace metadata | ||
capsuletenant.SyncNamespaceMetadata(tenant, ns) | ||
|
||
return nil |
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.
You still need to patch the admission, this does not do anything yet:
// sync namespace metadata | |
capsuletenant.SyncNamespaceMetadata(tenant, ns) | |
return nil | |
// sync namespace metadata | |
capsuletenant.SyncNamespaceMetadata(tenant, ns) | |
marshaled, err := json.Marshal(ns) | |
if err != nil { | |
response := admission.Errored(http.StatusInternalServerError, err) | |
return &response | |
} | |
response := admission.PatchResponseFromRaw(req.Object.Raw, marshaled) | |
return &response |
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.
You still need to patch the admission, this does not do anything yet:
yes, sorry, night coding on vacation is evil), patch was lost in changes. fixed
I'm. really sorry @CharlieR-o-o-t , i just merged the other feature which also causes some conflicts since it changes some of the metadata code. I would just put everything into your sync function so it's also considered at admission create, sahouldn't be too big of a change |
Signed-off-by: Siarhei Rasiukevich <s_rasiukevich@wargaming.net>
ab130bf
to
eb003c5
Compare
Signed-off-by: Siarhei Rasiukevich <s_rasiukevich@wargaming.net>
Signed-off-by: Siarhei Rasiukevich <s_rasiukevich@wargaming.net>
@oliverbaehler , I have also added additional commit on cordon webhook (26dbdf0). |
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.
Thank you very much for your efforts! 🚀
@oliverbaehler, As I can see by code only one handler will be executed onCreate, it's not clear for me purpose of InCapsuleGroups :/
only CordoningLabelHandler is executed now( |
Mh? Not sure what you are looking for, Cordoning does not even run
|
I mean that no matter how many handlers added to InCapsuleGroups, executed only first. |
Why would you reason that? |
Closes #1378
Sync metadata on namespace creation