Skip to content

Commit

Permalink
Fix machineClass migration
Browse files Browse the repository at this point in the history
  • Loading branch information
detiber committed Mar 1, 2019
1 parent 3c1f691 commit 6f5e8fb
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 6f5e8fb

Please sign in to comment.