-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🐛clusterctl: preflight for move operation #2313
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
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:master
from
fabriziopandini:clusterctl-move-preflight-providers
Feb 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,7 @@ import ( | |||||
| "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||||||
| "k8s.io/apimachinery/pkg/runtime" | ||||||
| clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" | ||||||
| clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" | ||||||
| "sigs.k8s.io/cluster-api/cmd/clusterctl/pkg/internal/test" | ||||||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||||||
| ) | ||||||
|
|
@@ -670,3 +671,128 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) { | |||||
| }) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| func Test_objectsMoverService_checkTargetProviders(t *testing.T) { | ||||||
| type fields struct { | ||||||
| fromProxy Proxy | ||||||
| } | ||||||
| type args struct { | ||||||
| toProxy Proxy | ||||||
| namespace string | ||||||
| } | ||||||
| tests := []struct { | ||||||
| name string | ||||||
| fields fields | ||||||
| args args | ||||||
| wantErr bool | ||||||
| }{ | ||||||
| { | ||||||
| name: "move objects in single namespace, all the providers in place (lazy matching)", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v1.0.0", "capi-system", ""). | ||||||
| WithProviderInventory("kubeadm", clusterctlv1.BootstrapProviderType, "v1.0.0", "cabpk-system", ""). | ||||||
| WithProviderInventory("capa", clusterctlv1.InfrastructureProviderType, "v1.0.0", "capa-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "ns1", // a single namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v1.0.0", "capi-system", "ns1"). | ||||||
| WithProviderInventory("kubeadm", clusterctlv1.BootstrapProviderType, "v1.0.0", "cabpk-system", "ns1"). | ||||||
| WithProviderInventory("capa", clusterctlv1.InfrastructureProviderType, "v1.0.0", "capa-system", "ns1"), | ||||||
| }, | ||||||
| wantErr: false, | ||||||
| }, | ||||||
| { | ||||||
| name: "move objects in single namespace, all the providers in place but with a newer version (lazy matching)", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.0.0", "capi-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "ns1", // a single namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.1.0", "capi-system", "ns1"), // Lazy matching | ||||||
| }, | ||||||
| wantErr: false, | ||||||
| }, | ||||||
| { | ||||||
| name: "move objects in all namespaces, all the providers in place (exact matching)", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v1.0.0", "capi-system", ""). | ||||||
| WithProviderInventory("kubeadm", clusterctlv1.BootstrapProviderType, "v1.0.0", "cabpk-system", ""). | ||||||
| WithProviderInventory("capa", clusterctlv1.InfrastructureProviderType, "v1.0.0", "capa-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "", // all namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v1.0.0", "capi-system", ""). | ||||||
| WithProviderInventory("kubeadm", clusterctlv1.BootstrapProviderType, "v1.0.0", "cabpk-system", ""). | ||||||
| WithProviderInventory("capa", clusterctlv1.InfrastructureProviderType, "v1.0.0", "capa-system", ""), | ||||||
| }, | ||||||
| wantErr: false, | ||||||
| }, | ||||||
| { | ||||||
| name: "move objects in all namespaces, all the providers in place but with a newer version (exact matching)", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.0.0", "capi-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "", // all namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.1.0", "capi-system", ""), | ||||||
| }, | ||||||
| wantErr: false, | ||||||
| }, | ||||||
| { | ||||||
| name: "move objects in all namespaces, not exact matching", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.0.0", "capi-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "", // all namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.1.0", "capi-system", "ns1"), // Lazy matching only | ||||||
| }, | ||||||
| wantErr: true, | ||||||
| }, | ||||||
| { | ||||||
| name: "fails if a provider is missing", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.0.0", "capi-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "", // all namespaces | ||||||
| toProxy: test.NewFakeProxy(), | ||||||
| }, | ||||||
| wantErr: true, | ||||||
| }, | ||||||
| { | ||||||
| name: "fails if a provider version is older than expected", | ||||||
| fields: fields{ | ||||||
| fromProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v2.0.0", "capi-system", ""), | ||||||
| }, | ||||||
| args: args{ | ||||||
| namespace: "", // all namespaces | ||||||
| toProxy: test.NewFakeProxy(). | ||||||
| WithProviderInventory("capi", clusterctlv1.CoreProviderType, "v1.0.0", "capi1-system", ""), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| }, | ||||||
| wantErr: true, | ||||||
| }, | ||||||
| } | ||||||
| for _, tt := range tests { | ||||||
| t.Run(tt.name, func(t *testing.T) { | ||||||
| o := &objectMover{ | ||||||
| fromProviderInventory: newInventoryClient(tt.fields.fromProxy, nil), | ||||||
| } | ||||||
| if err := o.checkTargetProviders(tt.args.namespace, newInventoryClient(tt.args.toProxy, nil)); (err != nil) != tt.wantErr { | ||||||
| t.Errorf("error = %v, wantErr %v", err, tt.wantErr) | ||||||
| } | ||||||
| }) | ||||||
| } | ||||||
| } | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.