-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ Extra validations for v1alpha3 -> v1alpha4 upgrade #4230
Conversation
@@ -143,6 +149,13 @@ func (u *providerUpgrader) ApplyPlan(coreProvider clusterctlv1.Provider, contrac | |||
log := logf.Log | |||
log.Info("Performing upgrade...") | |||
|
|||
// Check for multiple instances of the same provider for v1alpha4 contract. | |||
if contract == v1alpha4Contract { |
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.
Should this be contract > v1alpha3
? Is there an api version parsing library that can be used 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.
If we are moving this check into the doUpgrade
func, then we can rely on the upgrade plan and do check only if the current contract is v1alpha3
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 wasn't able to find the current contract in upgradePlan, I could only find upgradePlan.contract
which I believe is the contract that we want to upgrade to.
/test pull-cluster-api-test-main |
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 will be great to have a test for upgrade apply, might be in https://github.com/kubernetes-sigs/cluster-api/blob/master/cmd/clusterctl/client/cluster/upgrader_test.go
func Test_providerComponents_DeleteCoreProviderWebhookNamespace(t *testing.T) { | ||
t.Run("deletes capi-webhook-system namespace", func(t *testing.T) { | ||
g := NewWithT(t) | ||
labels := map[string]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.
Are these labels required for the test scenario?
providerTypeGrouping := make(map[string][]string) | ||
for _, p := range providers.Items { | ||
namespacedName := types.NamespacedName{Namespace: p.Namespace, Name: p.Name}.String() | ||
if providers, ok := providerTypeGrouping[p.Type]; ok { | ||
providerTypeGrouping[p.Type] = append(providers, namespacedName) | ||
} else { | ||
providerTypeGrouping[p.Type] = []string{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.
You can use provider.ManifestLabel() to uniquely identify a provider (it is a combination of type and 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 wanted to return the namespaces of the provider in the error message so that it's useful for the user.
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 got your point, but my concern is that we are redefining the concept of provider uniqueness (name + type) and provider instance (a combination of type, name + namespace), while there was an effort to centralizing those definitions on the Provider type and make them consistent across the codebase.
Please also note that the proposed implementation uses as criteria for detecting duplicates only type which is not correct because if you have infrastructure docker + infrastructure AWS it will block (instead this should pass).
The only use where we should black is when I have two instances of the same provider, where the same is defined by the uniqueness concept defined above (name + type). e,g if you have infrastructure AWS on ns1, infrastructure AWS on ns2 it should block
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.
Thanks for the explanation, Fabrizio. I think I misread your original comment thinking it was for the value in the map. Thanks for catching it. I've fixed it now and updated the tests to reflect that. Let me know what you think.
13408fe
to
0c54037
Compare
@fabriziopandini I've addressed the review comments, PTAL. |
/test pull-cluster-api-test-main |
return errors.Wrap(kerrors.NewAggregate(errs), "detected multiple instances of the same provider, "+ | ||
"multi-tenancy does not require to run multiple provider instances from v1alpha4: https://master.cluster-api.sigs.k8s.io/developer/architecture/controllers/support-multiple-instances.html") |
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.
return errors.Wrap(kerrors.NewAggregate(errs), "detected multiple instances of the same provider, "+ | |
"multi-tenancy does not require to run multiple provider instances from v1alpha4: https://master.cluster-api.sigs.k8s.io/developer/architecture/controllers/support-multiple-instances.html") | |
return errors.Wrap(kerrors.NewAggregate(errs), "detected multiple instances of the same provider, "+ | |
"but clusterctl v1alpha4 does not support this use case. See https://cluster-api.sigs.k8s.io/developer/architecture/controllers/support-multiple-instances.html for more details") |
@@ -49,6 +49,10 @@ type UpgradePlan struct { | |||
Providers []UpgradeItem | |||
} | |||
|
|||
const ( | |||
v1alpha4Contract = "v1alpha4" |
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 can use clusterv1.GroupVersion.Version
instead of this const, so the code will be more future proof
return | ||
} | ||
|
||
g.Expect(err).NotTo(HaveOccurred()) |
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.
Could we add a check ensuring the webhook namespace is removed?
0c54037
to
8bd9512
Compare
/retitle ✨ Extra validations for v1alpha3 -> v1alpha4 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.
/lgtm
/retest |
1 similar comment
/retest |
/milestone v0.4.0 |
/test pull-cluster-api-test-main |
1810198
to
ac44257
Compare
@shysank: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 this PR does / why we need it:
Validations for v1alpha3 -> v1alpha4 upgrade
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #4194