simplify the code

pull/11504/head
Ilya Zuyev 2021-05-26 13:41:10 -07:00
parent 773500bc74
commit 2a7f0dca85
1 changed files with 11 additions and 10 deletions

View File

@ -304,9 +304,8 @@ func deleteProfile(ctx context.Context, profile *config.Profile) error {
} }
func unpauseIfNeeded(profile *config.Profile) error { func unpauseIfNeeded(profile *config.Profile) error {
// there is a known issue with removing paused containerd kicbase container // there is a known issue with removing kicbase container with paused containerd containers inside
// unpause it before we delete it // unpause it before we delete it
if profile.Config.KubernetesConfig.ContainerRuntime != "containerd" { if profile.Config.KubernetesConfig.ContainerRuntime != "containerd" {
return nil return nil
} }
@ -321,27 +320,29 @@ func unpauseIfNeeded(profile *config.Profile) error {
if err != nil { if err != nil {
return err return err
} }
r, err := machine.CommandRunner(host) r, err := machine.CommandRunner(host)
if err != nil { if err != nil {
exit.Error(reason.InternalCommandRunner, "Failed to get command runner", err) exit.Error(reason.InternalCommandRunner, "Failed to get command runner", err)
} }
cr, err := cruntime.New(cruntime.Config{Type: profile.Config.KubernetesConfig.ContainerRuntime, Runner: r}) cr, err := cruntime.New(cruntime.Config{Type: profile.Config.KubernetesConfig.ContainerRuntime, Runner: r})
if err != nil { if err != nil {
exit.Error(reason.InternalNewRuntime, "Failed runtime", err) exit.Error(reason.InternalNewRuntime, "Failed runtime", err)
} }
paused, err := cluster.CheckIfPaused(cr, nil) paused, err := cluster.CheckIfPaused(cr, nil)
if err != nil { if err != nil {
return err return err
} }
if paused {
klog.Infof(`Unpause cluster %q.`, profile.Name) if !paused {
ids, err := cluster.Unpause(cr, r, nil) return nil
if err != nil {
return err
}
klog.Infof("Unpaused %v", ids)
} }
return nil
klog.Infof(`Unpause cluster %q.`, profile.Name)
_, err = cluster.Unpause(cr, r, nil)
return err
} }
func deleteHosts(api libmachine.API, cc *config.ClusterConfig) { func deleteHosts(api libmachine.API, cc *config.ClusterConfig) {