-
Notifications
You must be signed in to change notification settings - Fork 364
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
Enhance ClusterSet controller to support ClusterSet version upgrade #5250
Enhance ClusterSet controller to support ClusterSet version upgrade #5250
Conversation
/test-multicluster-e2e |
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 should still at least document how to manually convert the CRs to new version.
@@ -78,3 +81,49 @@ func parseServiceCIDRFromError(msg string) (string, error) { | |||
func NewClusterInfoResourceExportName(clusterID string) string { | |||
return clusterID + "-clusterinfo" | |||
} | |||
|
|||
func ValidateLocalClusterClaim(c client.Client, clusterSet *mcv1alpha2.ClusterSet) (clusterID ClusterID, err 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.
Does it need to be public?
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.
Renamed it to getClusterIDFromClusterClaim
.
multicluster/controllers/multicluster/common/controller_utils.go
Outdated
Show resolved
Hide resolved
} | ||
return clusterID, nil | ||
} | ||
return "", fmt.Errorf("the spec.clusterID field of ClusterSet %s is required", req.NamespacedName) |
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.
"clusterID" is not set in the ClusterSet %s spec"?
// Here we try to get the ClusterID from ClusterClaim before return any error. | ||
if clusterCalimCRDAvailable { | ||
clusterID, err := ValidateLocalClusterClaim(client, clusterSet) | ||
if err != nil { |
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.
Consider:
if err == nil {
return clusterID, nil
}
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.
Done.
multicluster/controllers/multicluster/common/controller_utils.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/common/controller_utils.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/leader/clusterset_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/member/clusterset_controller.go
Outdated
Show resolved
Hide resolved
f25ef66
to
5238f42
Compare
docs/multicluster/upgrade.md
Outdated
the `ClusterSet` CRD solely defines a ClusterSet. The name of a ClusterSet CR must match the | ||
ClusterSet ID, and a new `clusterID` field specifies the Cluster ID. | ||
|
||
To upgrade from a version older than v1.13, once you apply the latest manifests for an |
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 should talk about the new version MC Controller will still recognize old version ClusterClaim and ClusterSet CRs, but if the ClusterSet name does not match the ClusterSet ID, you should delete the ClusterSet CR and create a new one with using ClusterSet ID as the name.
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 found that the old codes already validate the ClusterSet ID and the ClusterSet CR's name to make sure they are the same, so I suppose there is no need to handle the recreate case. Both leader and member ClusterSet controller will call ValidateLocalClusterClaim
:
clusterID, clusterSetID, err := common.ValidateLocalClusterClaim(r.Client, clusterSet) |
The method will check if the ClusterSet ID and ClusterSet's name matched.
if clusterSet.Name != string(clusterSetID) { | |
err = fmt.Errorf("ClusterSet Name=%s is not same as ClusterClaim Value=%s for Name=%s", | |
clusterSet.Name, clusterSetID, multiclusterv1alpha2.WellKnownClusterClaimClusterSet) | |
return | |
} |
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. This is good to know.
5238f42
to
95335a0
Compare
docs/multicluster/upgrade.md
Outdated
the `ClusterSet` CRD solely defines a ClusterSet. The name of a ClusterSet CR must match the | ||
ClusterSet ID, and a new `clusterID` field specifies the Cluster ID. | ||
|
||
To upgrade from a version older than v1.13, once you apply the latest manifests for an |
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 should still revise the paragraph to explain the process clearer. Consider the following:
"After upgrading Antrea Multi-cluster Controller from a version older than v1.13, the new version Multi-cluster Controller can still recognize and work with the old version ClusterClaim and ClusterSet CRs. However, we still suggest updating the ClusterSet CR to the new version after upgrading Multi-cluster Controller. You just need to update the existing ClusterSet
CR and add the right clusterID
to the spec."
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.
Updated, thanks.
docs/multicluster/upgrade.md
Outdated
version of Antrea Multi-cluster controller will update the existing `ClusterSet` CR with | ||
the valid Cluster ID. You can verify this via `kubectl get clusterclaim id.k8s.io -o json -n kube-system | jq -r '.value'`. | ||
|
||
Once you finish the cluster upgrade, you should also delete the `ClusterClaim` CRD |
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.
"You may also delete ClusterClaim
CRD after the upgrade, ..."
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.
Done.
95335a0
to
c84a234
Compare
/test-multicluster-e2e |
c84a234
to
4eaf553
Compare
Refine ClusterSet controller to watch ClusterClaims to handle the ClusterSet upgrade from v1alpha1 to v1alpha2. When the ClusterID is not in ClusterSet spec, controller will try to get ClusterID from ClusterClaims. Signed-off-by: Lan Luo <[email protected]>
4eaf553
to
5abd2c6
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.
LGTM
/test-multicluster-e2e |
/skip-all |
Refine ClusterSet controller to watch ClusterClaims to handle the ClusterSet upgrade from v1alpha1 to v1alpha2. When the ClusterID is not in ClusterSet spec, controller will try to get ClusterID from ClusterClaims.