-
Notifications
You must be signed in to change notification settings - Fork 890
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: List&watch mcs and service, reconcile the work in execution namespace #4323
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #4323 +/- ##
==========================================
- Coverage 51.99% 51.98% -0.01%
==========================================
Files 242 242
Lines 23984 23990 +6
==========================================
+ Hits 12471 12472 +1
- Misses 10832 10837 +5
Partials 681 681
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
0258393
to
cd0c339
Compare
limitations under the License. | ||
*/ | ||
|
||
package mcs |
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.
To differentiate the current mcs controller, I believe it would be best to move it to a different directory.
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.
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.
It's ok to put the controller in this package. the user-facing controller name is defined at https://github.com/karmada-io/karmada/pull/4323/files#diff-a111978a679a9f03e49c67a43ecb913299d153e59ce48d2d30f5029f27ab601aR227.
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 think we should also put it in another folder for easier code analysis and reading.
Review continually |
const ControllerName = "mcs-controller" | ||
|
||
// MCSControllerFinalizer is added to Cluster to ensure work is deleted before itself is deleted. | ||
const MCSControllerFinalizer = "karmada.io/mcs-controller" |
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.
Put this in pkg/util/constants.go
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.
ok
const MCSControllerFinalizer = "karmada.io/mcs-controller" | ||
|
||
// CrossClusterEventReason is indicates the reason of CrossCluster event. | ||
const CrossClusterEventReason string = "MCSCrossCluster" |
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.
Put this in pkg/events/events.go
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.
ok
return controllerruntime.Result{}, nil | ||
} | ||
|
||
func (c *MCSController) syncSvcWorkToClusters( |
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.
How about using name syncSVCWorkToClusters
?
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.
ok
limitations under the License. | ||
*/ | ||
|
||
package mcs |
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.
const MCSServiceAppliedConditionType = "ServiceApplied" | ||
|
||
// MCSWorkIDLabel is indicates the label of work created by mcs. | ||
const MCSWorkIDLabel = "mcs.karmada.io/mcs-id" |
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.
Let's use MultiClusterServicePermanentIDLabel
instead of MCSWorkIDLabel
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.
ok
}) | ||
} | ||
|
||
func (c *MCSController) getMultiClusterServiceID(mcs *networkingv1alpha1.MultiClusterService) (string, error) { |
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 ID will be added in mutating webhook: https://github.com/karmada-io/karmada/blob/02b9ff4e11f6bbf67655335fd3c4d1b45f223b25/pkg/webhook/multiclusterservice/mutating.go.
But I am not sure whether we should have this part, Just in case the user forgets to configure the webhook. cc @RainbowMango
} | ||
|
||
// MCSContainCrossClusterType checks weather the MultiClusterService contains CrossCluster type. | ||
func MCSContainCrossClusterType(mcs *networkingv1alpha1.MultiClusterService) bool { |
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.
Let's put this in file
karmada/pkg/util/helper/mcs.go
Line 103 in 02b9ff4
func MultiClusterServiceCrossClusterEnabled(mcs *networkingv1alpha1.MultiClusterService) bool { |
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.
ok
} | ||
|
||
// We only care about the update events below: | ||
if equality.Semantic.DeepEqual(mcsOld.Annotations, mcsNew.Annotations) && |
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 is this judgment necessary?
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.
Currently, there don't need to pay attention to other changes, such as label.
func (c *MCSController) deleteServiceWork( | ||
ctx context.Context, | ||
mcs *networkingv1alpha1.MultiClusterService, | ||
retainClusters sets.Set[string], |
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.
retainClusters
look useless?
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.
It's useful to exclude clusters where we don't want to delete service work.
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.
/assign
) | ||
|
||
// ControllerName is the controller name that will be used when reporting events. | ||
const ControllerName = "mcs-controller" |
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.
const ControllerName = "mcs-controller" | |
const ControllerName = "multiclusterservice-controller" |
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.
ok
pkg/util/constants.go
Outdated
@@ -89,6 +89,9 @@ const ( | |||
// ClusterResourceBindingControllerFinalizer is added to ClusterResourceBinding to ensure related Works are deleted | |||
// before ClusterResourceBinding itself is deleted. | |||
ClusterResourceBindingControllerFinalizer = "karmada.io/cluster-resource-binding-controller" | |||
|
|||
// MCSControllerFinalizer is added to Cluster to ensure service work is deleted before itself is deleted. | |||
MCSControllerFinalizer = "karmada.io/mcs-controller" |
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.
MCSControllerFinalizer = "karmada.io/mcs-controller" | |
MCSControllerFinalizer = "karmada.io/multiclusterservice-controller" |
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.
ok
// MCSServiceAppliedConditionType is indicates the condition type of mcs service applied. | ||
MCSServiceAppliedConditionType = "ServiceApplied" |
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.
Please move the events to pkg/events/events.go
.
@jwcesign In my opinion, if we report a warning
event and we need to report another normal
event to cancel the event, right?
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 am not sure, but we should report the normal event.
682dcfb
to
2802916
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.
I am ok now, cc @RainbowMango for checking
Signed-off-by: z00623291 <[email protected]>
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Referring to #4287
Which issue(s) this PR fixes:
Part of #4292
Special notes for your reviewer:
none
Does this PR introduce a user-facing change?: