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: add support for shared namespace ownership #1667

Closed
wants to merge 3 commits into from

Conversation

isugimpy
Copy link

Fixes #1654

Open to changing this in whatever way makes sense. Thanks for the quick feedback on the issue!

@isugimpy isugimpy requested review from a team as code owners March 21, 2024 11:51
Copy link

netlify bot commented Mar 21, 2024

Deploy Preview for docs-kargo-akuity-io ready!

Name Link
🔨 Latest commit 85e6123
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-akuity-io/deploys/6601b3f6f735b60008e7881d
😎 Deploy Preview https://deploy-preview-1667.kargo.akuity.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@krancour
Copy link
Member

@isugimpy we're pushing really hard to wrap up v0.5.0 right now, so I'm going to add this to the v0.6.0 milestone and we'll get to reviewing this in earnest probably next week.

@krancour krancour added this to the v0.6.0 milestone Mar 21, 2024
@isugimpy
Copy link
Author

No worries! If I need it for testing I can always build locally. Good luck on 0.5.0!

Copy link
Contributor

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! 🍒

While we are waiting for the v0.5.0 release branch to be cut, allowing this to be merged. I managed to do an initial round of review.

)
ns.OwnerReferences = []metav1.OwnerReference{*ownerRef}
ns.Labels[kargoapi.ProjectLabelKey] == kargoapi.LabelTrueValue {
if len(ns.OwnerReferences) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better to use a switch here:

switch {
case len(ns.OwnerReferences) == 0:
   // Set owner reference
case ns.Labels[kargoapi.AllowSharedOwnershipLabelKey] == kargoapi.LabelTrueValue:
   // Append owner reference
default:
   // Return error
}

@@ -16,4 +16,6 @@ const (
LabelTrueValue = "true"

FinalizerName = "kargo.akuity.io/finalizer"

AllowSharedOwnershipLabelKey = "kargo.akuity.io/allow-shared-ownership"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite lengthy and cumbersome to type. Given this, I am wondering if it could for example be changed to kargo.akuity.io/shared-owner. Which gets the same message across.

Adjusted label value to be shorter
Moved from if/else to switch/case

Signed-off-by: Jayme Howard <[email protected]>
@isugimpy isugimpy requested a review from hiddeco March 25, 2024 13:37
@isugimpy
Copy link
Author

@hiddeco Thanks for the feedback! Addressed both as requested!

@isugimpy
Copy link
Author

isugimpy commented Mar 25, 2024

One quick clarifying thing. I neglected to set the controller property on the ownerReference to false before. This fixes that to make sure there's no ownership collision there. If that's not desirable, would love to discuss further.

@krancour
Copy link
Member

krancour commented Apr 9, 2024

Test driving.

Copy link

codecov bot commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.18%. Comparing base (8b657d3) to head (85e6123).
Report is 78 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1667      +/-   ##
==========================================
+ Coverage   43.81%   44.18%   +0.37%     
==========================================
  Files         202      202              
  Lines       12935    13061     +126     
==========================================
+ Hits         5667     5771     +104     
- Misses       7026     7045      +19     
- Partials      242      245       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krancour
Copy link
Member

krancour commented Apr 9, 2024

@isugimpy have you gotten this to work end-to-end?

Similar changes should be required to the Project webhook...

It handles synchronous Project initialization, which is often required if someone kubectl apply -f ... or kargo apply -f ... a file that looks like this, which is common:

apiVersion: kargo.akuity.io/v1alpha1
kind: Project
metadata:
  name: kargo-demo
---
# Many more resources that need to go in the kargo-demo namespace, which must exist

@krancour
Copy link
Member

@isugimpy I think this just needs some webhook changes. If you're busy, I'm happy to take this the last mile. Your call.

@krancour
Copy link
Member

As we're approaching a v0.6.0 release and this non-critical PR has outstanding work still, deferring this to v0.7.0.

@krancour krancour modified the milestones: v0.6.0, v0.7.0 Apr 22, 2024
@isugimpy
Copy link
Author

@krancour Hey, I'm sorry about not responding. Been on vacation and didn't see this. I don't think I did a full end to end of this, actually. I remember testing briefly, but it's been a month or so and it's a bit fuzzy. You're quite welcome to take this across the line if you'd like! I probably won't be able to get back to it for a little bit.

@krancour
Copy link
Member

@isugimpy you did all the hard work. Will try to get this over the line in the v0.7.0 timeframe.

@krancour
Copy link
Member

Closing in favor of #2076

@krancour krancour closed this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Shared Namespace Ownership for Projects
3 participants