Skip to content

Commit

Permalink
Fix machineClass migration
Browse files Browse the repository at this point in the history
  • Loading branch information
detiber committed Feb 28, 2019
1 parent d9a43a1 commit 611552e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/clusterctl/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ go_library(
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
Expand Down
10 changes: 5 additions & 5 deletions cmd/clusterctl/phases/pivot.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func pivot(from, to clusterclient.Client, providerComponents string) error {
return err
}

if err := deleteMachineClasses(from, to, machineClasses); err != nil {
if err := deleteMachineClasses(from, machineClasses); err != nil {
return err
}

Expand All @@ -149,25 +149,25 @@ func moveClusters(from, to clusterclient.Client, clusters []*clusterv1.Cluster)
return nil
}

func deleteMachineClasses(from, to clusterclient.Client, machineClasses []*clusterv1.MachineClass) error {
func deleteMachineClasses(client clusterclient.Client, machineClasses []*clusterv1.MachineClass) error {
machineClassNames := make([]string, 0, len(machineClasses))
for _, mc := range machineClasses {
machineClassNames = append(machineClassNames, mc.Name)
}
klog.V(4).Infof("Preparing to delete MachineClasses: %v", machineClassNames)

for _, mc := range machineClasses {
if err := deleteMachineClass(from, to, mc); err != nil {
if err := deleteMachineClass(client, mc); err != nil {
return errors.Wrapf(err, "failed to delete MachineClass %s:%s", mc.Namespace, mc.Name)
}
}
return nil
}

func deleteMachineClass(from, to clusterclient.Client, machineClass *clusterv1.MachineClass) error {
func deleteMachineClass(client clusterclient.Client, machineClass *clusterv1.MachineClass) error {
// New objects cannot have a specified resource version. Clear it out.
machineClass.SetResourceVersion("")
if err := to.DeleteMachineClass(machineClass.Namespace, machineClass.Name); err != nil {
if err := client.DeleteMachineClass(machineClass.Namespace, machineClass.Name); err != nil {
return errors.Wrapf(err, "error deleting MachineClass %s/%s from source cluster", machineClass.Namespace, machineClass.Name)
}

Expand Down
2 changes: 0 additions & 2 deletions cmd/clusterctl/validation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ go_library(
"//pkg/apis/cluster/v1alpha1:go_default_library",
"//pkg/controller/noderefutil:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library",
Expand All @@ -34,7 +33,6 @@ go_test(
"//pkg/apis/cluster/common:go_default_library",
"//pkg/apis/cluster/v1alpha1:go_default_library",
"//pkg/apis/cluster/v1alpha1/testutil:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
Expand Down

0 comments on commit 611552e

Please sign in to comment.