1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-14 06:00:53 +00:00

Remove statefile for dind remove

This commit is contained in:
Sebastiaan van Steenis
2020-07-15 10:53:05 +02:00
committed by Denise
parent f8e48f67c3
commit 12b4dcaf59
4 changed files with 11 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ func (c *Cluster) CleanupNodes(ctx context.Context) error {
func (c *Cluster) CleanupFiles(ctx context.Context) error { func (c *Cluster) CleanupFiles(ctx context.Context) error {
pki.RemoveAdminConfig(ctx, c.LocalKubeConfigPath) pki.RemoveAdminConfig(ctx, c.LocalKubeConfigPath)
removeStateFile(ctx, c.StateFilePath) RemoveStateFile(ctx, c.StateFilePath)
return nil return nil
} }

View File

@@ -264,7 +264,7 @@ func ReadStateFile(ctx context.Context, statePath string) (*FullState, error) {
return rkeFullState, nil return rkeFullState, nil
} }
func removeStateFile(ctx context.Context, statePath string) { func RemoveStateFile(ctx context.Context, statePath string) {
log.Infof(ctx, "Removing state file: %s", statePath) log.Infof(ctx, "Removing state file: %s", statePath)
if err := os.Remove(statePath); err != nil { if err := os.Remove(statePath); err != nil {
logrus.Warningf("Failed to remove state file: %v", err) logrus.Warningf("Failed to remove state file: %v", err)

View File

@@ -166,8 +166,12 @@ func clusterRemoveDind(ctx *cli.Context) error {
return err return err
} }
} }
localKubeConfigPath := pki.GetLocalKubeConfig(filePath, "")
// remove the kube config file // remove the kube config file
localKubeConfigPath := pki.GetLocalKubeConfig(filePath, "")
pki.RemoveAdminConfig(context.Background(), localKubeConfigPath) pki.RemoveAdminConfig(context.Background(), localKubeConfigPath)
// remove cluster state file
stateFilePath := cluster.GetStateFilePath(filePath, "")
cluster.RemoveStateFile(context.Background(), stateFilePath)
return err return err
} }

View File

@@ -120,6 +120,10 @@ func RmoveDindContainer(ctx context.Context, dindAddress string) error {
if err := cli.ContainerRemove(ctx, containerName, types.ContainerRemoveOptions{ if err := cli.ContainerRemove(ctx, containerName, types.ContainerRemoveOptions{
Force: true, Force: true,
RemoveVolumes: true}); err != nil { RemoveVolumes: true}); err != nil {
if client.IsErrNotFound(err) {
logrus.Debugf("[remove/%s] Container doesn't exist on host [%s]", containerName, cli.DaemonHost())
return nil
}
return fmt.Errorf("Failed to remove dind container [%s] on host [%s]: %v", containerName, cli.DaemonHost(), err) return fmt.Errorf("Failed to remove dind container [%s] on host [%s]: %v", containerName, cli.DaemonHost(), err)
} }
logrus.Infof("[%s] Successfully Removed dind container [%s] on host [%s]", DINDPlane, containerName, cli.DaemonHost()) logrus.Infof("[%s] Successfully Removed dind container [%s] on host [%s]", DINDPlane, containerName, cli.DaemonHost())