From 64a6f4266df8a5ae3e75d01dd350946bfe97ffe3 Mon Sep 17 00:00:00 2001 From: Chuck Ha Date: Tue, 20 Aug 2019 20:01:31 +0100 Subject: [PATCH] Fix DockerMachine delete for first control plane Signed-off-by: Chuck Ha --- docker/actions/cluster_actions.go | 4 ++++ docker/actions/kind.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/actions/cluster_actions.go b/docker/actions/cluster_actions.go index 85f0e1eae006..7a087387c161 100644 --- a/docker/actions/cluster_actions.go +++ b/docker/actions/cluster_actions.go @@ -169,6 +169,10 @@ func DeleteClusterNode(clusterName, nodeName string) error { if err != nil { return errors.Wrap(err, "failed to list all control planes") } + // If there is only one control plane being deleted do not update the corev1.Node list + if len(allControlPlanes) == 1 { + return nil + } var node nodes.Node // pick one that doesn't match the node name we are trying to delete for _, n := range allControlPlanes { diff --git a/docker/actions/kind.go b/docker/actions/kind.go index 3a576ee23b16..f3450d5b2963 100644 --- a/docker/actions/kind.go +++ b/docker/actions/kind.go @@ -155,7 +155,7 @@ func (m *MachineActions) DeleteControlPlane(clusterName, nodeName string) error fmt.Sprintf("name=%s$", nodeName), ) if err != nil { - return nil + return errors.WithStack(err) } // assume it's already deleted @@ -175,7 +175,7 @@ func (m *MachineActions) DeleteControlPlane(clusterName, nodeName string) error // Delete the infrastructure log.Info("Deleting node") if err := nodes.Delete(node); err != nil { - return err + return errors.WithStack(err) } return ConfigureLoadBalancer(clusterName) }