Skip to content

Conversation

CharlieR-o-o-t
Copy link
Contributor

Closes #1378

Sync metadata on namespace creation

Copy link

netlify bot commented Feb 16, 2025

Deploy Preview for capsule-documentation canceled.

Name Link
🔨 Latest commit fd83079
🔍 Latest deploy log https://app.netlify.com/sites/capsule-documentation/deploys/67c95b18f7cd4000087b3610

@oliverbaehler
Copy link
Collaborator

Hey until the new implementation is done i am happy to consider this one, could you adsd one e2e test?

@CharlieR-o-o-t CharlieR-o-o-t force-pushed the main branch 7 times, most recently from f900474 to 8c03103 Compare March 6, 2025 00:02
@CharlieR-o-o-t
Copy link
Contributor Author

CharlieR-o-o-t commented Mar 6, 2025

Hello @oliverbaehler
Apologies for the delay, was on vacation.

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:
ghcr.io/alegrey91/harpoon:latest is a broken build—there is no execute bit set on the binary, causing the container to crash during trace-e2e. As a workaround, I switched Harpoon back to Docker Hub.

Please take a look when you'll have time.
pipeline should be ok this time.

@CharlieR-o-o-t
Copy link
Contributor Author

/retest

@CharlieR-o-o-t
Copy link
Contributor Author

Have no failed test in trace-e2e on my ubuntu workstation.
Doesn't look like related to my change. Will figure out.

@Svarrogh1337
Copy link
Collaborator

Additionally, I encountered issues with the Harpoon image: ghcr.io/alegrey91/harpoon:latest is a broken build—there is no execute bit set on the binary, causing the container to crash during trace-e2e. As a workaround, I switched Harpoon back to Docker Hub.

Please take a look when you'll have time. pipeline should be ok this time.

You can git cherry-pick f06c38f280bcf524d6b58b172d4e86800c25f138 for fix. It's also already been merged into main, so you can take it from there too.

@CharlieR-o-o-t CharlieR-o-o-t force-pushed the main branch 2 times, most recently from 13815a9 to 16ba36f Compare April 27, 2025 21:57
@CharlieR-o-o-t
Copy link
Contributor Author

CharlieR-o-o-t commented Apr 27, 2025

@Svarrogh1337 @oliverbaehler , apologies, just found time for this.
Latest harpoon produces deadlock, I can reproduce it only in github CI.
I just tried to remove harpoon from entrypoint for test purposes and everything is okay.

On my ubuntu workstation everything is ok even with harpoon:
Screenshot_20250428_011221

Could you confirm?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

@oliverbaehler
Copy link
Collaborator

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

@CharlieR-o-o-t
Copy link
Contributor Author

@oliverbaehler , I have made changes considering last mutation feature, could you take a look?

Copy link
Collaborator

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

Comment on lines 50 to 53
// sync namespace metadata
capsuletenant.SyncNamespaceMetadata(tenant, ns)

return nil
Copy link
Collaborator

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:

Suggested change
// 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

Copy link
Contributor Author

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

@oliverbaehler
Copy link
Collaborator

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>
@CharlieR-o-o-t CharlieR-o-o-t force-pushed the main branch 5 times, most recently from ab130bf to eb003c5 Compare May 8, 2025 21:55
Signed-off-by: Siarhei Rasiukevich <s_rasiukevich@wargaming.net>
Signed-off-by: Siarhei Rasiukevich <s_rasiukevich@wargaming.net>
@CharlieR-o-o-t
Copy link
Contributor Author

@oliverbaehler ,
Everything mentioned were fixed. Thank you for review.

I have also added additional commit on cordon webhook (26dbdf0).
Internal error was not returned.

Copy link
Collaborator

@oliverbaehler oliverbaehler left a 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 oliverbaehler merged commit f85b618 into projectcapsule:main May 9, 2025
14 checks passed
@CharlieR-o-o-t
Copy link
Contributor Author

CharlieR-o-o-t commented May 26, 2025

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

@oliverbaehler, As I can see by code only one handler will be executed onCreate, it's not clear for me purpose of InCapsuleGroups :/

for _, hndl := range h.handlers {

only CordoningLabelHandler is executed now(

@oliverbaehler
Copy link
Collaborator

Mh? Not sure what you are looking for, Cordoning does not even run OnCreate?

InCapsuleGroups tells the webhook, that the user submitting the admission (or rather one of their groups) must be mentioned in the capsuleCOnfiguration. Otherwise the admission is just allowed. This is not to interfere with non tenant operations.

@CharlieR-o-o-t
Copy link
Contributor Author

I mean that no matter how many handlers added to InCapsuleGroups, executed only first.
This breaks the logic with mutation.

@oliverbaehler
Copy link
Collaborator

Why would you reason that? executed only first - not true at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sync namespace metadata on creation.
3 participants