mirror of
https://github.com/rancher/rke.git
synced 2025-04-27 11:21:08 +00:00
Remove statefile for dind remove
This commit is contained in:
parent
f8e48f67c3
commit
12b4dcaf59
@ -70,7 +70,7 @@ func (c *Cluster) CleanupNodes(ctx context.Context) error {
|
||||
|
||||
func (c *Cluster) CleanupFiles(ctx context.Context) error {
|
||||
pki.RemoveAdminConfig(ctx, c.LocalKubeConfigPath)
|
||||
removeStateFile(ctx, c.StateFilePath)
|
||||
RemoveStateFile(ctx, c.StateFilePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ func ReadStateFile(ctx context.Context, statePath string) (*FullState, error) {
|
||||
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)
|
||||
if err := os.Remove(statePath); err != nil {
|
||||
logrus.Warningf("Failed to remove state file: %v", err)
|
||||
|
@ -166,8 +166,12 @@ func clusterRemoveDind(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
localKubeConfigPath := pki.GetLocalKubeConfig(filePath, "")
|
||||
// remove the kube config file
|
||||
localKubeConfigPath := pki.GetLocalKubeConfig(filePath, "")
|
||||
pki.RemoveAdminConfig(context.Background(), localKubeConfigPath)
|
||||
|
||||
// remove cluster state file
|
||||
stateFilePath := cluster.GetStateFilePath(filePath, "")
|
||||
cluster.RemoveStateFile(context.Background(), stateFilePath)
|
||||
return err
|
||||
}
|
||||
|
@ -120,6 +120,10 @@ func RmoveDindContainer(ctx context.Context, dindAddress string) error {
|
||||
if err := cli.ContainerRemove(ctx, containerName, types.ContainerRemoveOptions{
|
||||
Force: true,
|
||||
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)
|
||||
}
|
||||
logrus.Infof("[%s] Successfully Removed dind container [%s] on host [%s]", DINDPlane, containerName, cli.DaemonHost())
|
||||
|
Loading…
Reference in New Issue
Block a user