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

Feat: enable owner references #2688

Merged
merged 31 commits into from
Aug 9, 2024
Merged

Conversation

FxKu
Copy link
Member

@FxKu FxKu commented Jul 8, 2024

This a follow up to #2199 with some greater changes. The most important part of owner references is the cascaded removal of child resources which bypasses the delete protection offered by our operator.

Quick reminder about delete protection: this checks pre-defined annotations before calling delete code but cannot block the actual kubectl delete call itself. This you could only achieve with a K8s admission controller which, for example, does the same annotation checks.

We use the latter at Zalando, but some folks out there might rely on the protection by the operator. Therefore, we should not enable owner references by default but make it configurable.

#2199 also lacked code to update existing resources once you start using owner references or vice versa remove them. Like with the recently added annotation inheritance, this produced many code extensions. I’ve also found some oversights from #2657 which I’ve fixed along the way. All owner references syncs are done with Update API calls, which requires extending the RBAC.

A new e2e test is added which tests syncing owner references in both directions and deleting the acid-test-cluster cascadingly which was previously done in the multi namespace test. Some unit test were extended, too.

closes #2199
fixes #498

@FxKu FxKu added this to the 1.13.0 milestone Jul 8, 2024
@FxKu FxKu marked this pull request as draft July 8, 2024 14:20
@FxKu FxKu changed the title Mbegenau feat 498 owner references Feat: enable owner references Jul 18, 2024
@fm2022aa
Copy link

great

@FxKu FxKu marked this pull request as ready for review July 22, 2024 07:47
@FxKu FxKu added the minor label Jul 29, 2024
Copy link
Member

@hughcapet hughcapet left a comment

Choose a reason for hiding this comment

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

Don't we need OwnerReferences on logical backup jobs?

@@ -957,9 +970,15 @@ func (c *Cluster) updateSecret(
userMap[userKey] = pwdUser
}

if !reflect.DeepEqual(secret.ObjectMeta.OwnerReferences, generatedSecret.ObjectMeta.OwnerReferences) {
updateSecret = true
updateSecretMsg = fmt.Sprintf("secret %s owner references do not match the current ones", secretName)
Copy link
Member

Choose a reason for hiding this comment

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

i am wondering, shouldn't we concatenate all the update msgs instead of re-assigning?

Copy link
Member Author

Choose a reason for hiding this comment

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

The other cases are mutual exclusive to one another. This line here is the only case that might happen additionally. But given that enabling owner references is probably a one time operation, I don't think it's worth to add more logic.

pkg/cluster/sync.go Outdated Show resolved Hide resolved
pkg/cluster/cluster.go Outdated Show resolved Hide resolved
@hughcapet
Copy link
Member

👍

1 similar comment
@FxKu
Copy link
Member Author

FxKu commented Aug 9, 2024

👍

@FxKu FxKu merged commit a87307e into master Aug 9, 2024
12 checks passed
@FxKu FxKu deleted the mbegenau-feat-498-ownerReferences branch August 9, 2024 15:58
@barthy1
Copy link

barthy1 commented Aug 16, 2024

Thank you for this great work!
When this feature is going to be released?

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

Successfully merging this pull request may close these issues.

Add ownerReference to managed entities
5 participants