-
Notifications
You must be signed in to change notification settings - Fork 386
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
Auto update ClusterSet and MemberClusterAnnounce in leader cluster #3956
Conversation
@luolanzone Could you please take a quick review for this WIP PR. Thanks. |
Codecov Report
@@ Coverage Diff @@
## main #3956 +/- ##
==========================================
- Coverage 64.50% 64.46% -0.05%
==========================================
Files 294 294
Lines 43726 43827 +101
==========================================
+ Hits 28206 28253 +47
- Misses 13236 13270 +34
- Partials 2284 2304 +20
|
@hjiajing Could you please fix the unit test failure? https://github.com/antrea-io/antrea/runs/7126092905?check_suite_focus=true |
@luolanzone Sure. I will fix it now |
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/member_clusterset_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/member_clusterset_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
e55252a
to
0ea8255
Compare
@hjiajing Could you resolve the conflicts? thanks. |
1b35a35
to
26b7eae
Compare
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook_test.go
Show resolved
Hide resolved
39c2871
to
2ddbdd6
Compare
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} | ||
if len(clusterSet.Spec.Leaders) != 1 { |
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.
Maybe you can remove this check and add schema validation like this: https://github.com/antrea-io/antrea/pull/3964/files#diff-d91c75a71bf454b846eb3998698d615fadf6108177e9624428572d6440887962R42-R43,
You can refer to the change to add this refinement to this PR, so it won't have any merge dependency between two commits.
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.
And this one?
multicluster/controllers/multicluster/member_clusterset_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
} | ||
// If err != nil, probably ClusterClaims were deleted during the processing of MemberClusterAnnounce. |
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 we move the error out of the "if" block?
err here should be returned by r.List() at line 131? If so, I do not feel it is relevant to the comment. @luolanzone : could you check?
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.
@jianjuns yes, you are right. I feel original comment and logic doesn't handle the case correctly. If all ClusterClaims are deleted, it should be empty list instead of an error. I think it should retry if there is an error. @hjiajing Could you double check and refine this part? we may leave ClusterClaim webhook part in a new PR.
multicluster/controllers/multicluster/member_clusterset_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
} | ||
// If err != nil, probably ClusterClaims were deleted during the processing of MemberClusterAnnounce. |
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.
We need to handle MemberClusterAnnounce deletion (comments in line 109 are no longer valid?).
a0c5bec
to
e49b844
Compare
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
bbaa605
to
bb7b755
Compare
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
@@ -108,6 +111,8 @@ func (r *MemberClusterAnnounceReconciler) Reconcile(ctx context.Context, req ctr | |||
r.mapLock.Lock() | |||
defer r.mapLock.Unlock() | |||
|
|||
// If !ok, it means member not found. If this happens, the MemberClusterAnnounce should soon be deleted. | |||
// Nothing to do here. | |||
if data, ok := r.timerData[common.ClusterID(memberAnnounce.ClusterID)]; ok { |
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.
@luolanzone : I feel we should revisit all these ClusterSet / cluster status code. I have the following question:
- Do we really need leader cluster ID in the MemberAnnounce?
- Do we still need all status conditions after we remove election?
- Add/RemoveMember() need not to be called by ClusterSet changes, after we change to auto-update ClusterSet, but we can start to maintain the timerdata once MemberClusterAnnounce is created?
Could you please look into the code to understand the whole status update logic, and clean up the code?
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.
Maybe you can first summarize what conditions we have, and they are set for what cases.
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.
@luolanzone : a reminder for you.
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.
Sure, I will check this part, thanks for reminding.
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
309af10
to
8fcbbb6
Compare
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/memberclusterannounce_controller.go
Outdated
Show resolved
Hide resolved
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 do not have further comments for this PR, except for a reminder for adding code comments.
@luolanzone : would you take another look before we can merge?
@@ -108,6 +111,8 @@ func (r *MemberClusterAnnounceReconciler) Reconcile(ctx context.Context, req ctr | |||
r.mapLock.Lock() | |||
defer r.mapLock.Unlock() | |||
|
|||
// If !ok, it means member not found. If this happens, the MemberClusterAnnounce should soon be deleted. | |||
// Nothing to do here. | |||
if data, ok := r.timerData[common.ClusterID(memberAnnounce.ClusterID)]; ok { |
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.
@luolanzone : a reminder for you.
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.
@hjiajing Could you rebase the PR? A few questions in the comments
@@ -63,10 +64,15 @@ func runLeader(o *Options) error { | |||
if err = memberClusterStatusManager.SetupWithManager(mgr); err != nil { | |||
return fmt.Errorf("error creating MemberClusterAnnounce controller: %v", err) | |||
} | |||
|
|||
noCachedClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme(), Mapper: mgr.GetRESTMapper()}) |
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.
Leader is running in a Namespace scope, it's supposed to watch those resources in the same Namespace where the leader controller is running. I didn't see you set the Namespace here.
Do we really need to use no cached client in order to remove the list
in the RBAC? I feel it's better to keep the same as other controllers. @jianjuns any comment for this?
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 do not know all the implication here, but I would watch only in the same Namespace.
Another question - in RBAC configuration, we do not create a "Role" to restrict the permissions to only the “multcluster" Namespace? @luolanzone
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.
@jianjuns we defined a 'Role' antrea-mc-controller-role
in antrea-multicluster-leader-namespaced.yml, Antrea mc-controller will only be able to watch resources under “antrea-multicluster" Namespace.
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
2962ce8
to
1e02aa1
Compare
multicluster/controllers/multicluster/member_clusterset_controller.go
Outdated
Show resolved
Hide resolved
@@ -63,10 +64,15 @@ func runLeader(o *Options) error { | |||
if err = memberClusterStatusManager.SetupWithManager(mgr); err != nil { | |||
return fmt.Errorf("error creating MemberClusterAnnounce controller: %v", err) | |||
} | |||
|
|||
noCachedClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme(), Mapper: mgr.GetRESTMapper()}) |
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 do not know all the implication here, but I would watch only in the same Namespace.
Another question - in RBAC configuration, we do not create a "Role" to restrict the permissions to only the “multcluster" Namespace? @luolanzone
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 overall, a few nits
@@ -63,10 +64,15 @@ func runLeader(o *Options) error { | |||
if err = memberClusterStatusManager.SetupWithManager(mgr); err != nil { | |||
return fmt.Errorf("error creating MemberClusterAnnounce controller: %v", err) | |||
} | |||
|
|||
noCachedClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme(), Mapper: mgr.GetRESTMapper()}) |
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.
@jianjuns we defined a 'Role' antrea-mc-controller-role
in antrea-multicluster-leader-namespaced.yml, Antrea mc-controller will only be able to watch resources under “antrea-multicluster" Namespace.
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Outdated
Show resolved
Hide resolved
multicluster/cmd/multicluster-controller/memberclusterannounce_webhook.go
Show resolved
Hide resolved
Signed-off-by: hujiajing <hjiajing@vmware.com>
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 overall @jianjuns Could you help to take a look if this is ready to merge? thanks.
/test-multicluster-e2e |
No further comment from me. |
Auto update ClusetSet and MemberClusterAnnounce in the leader cluster.
spec.members
.MemberClusterAnnounce
in the leader cluster will be deleted. The member cluster will be removed from thespec.members
.