Skip to content

Commit

Permalink
Fix force refine and delete option
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot committed Nov 23, 2023
2 parents 8ace29e + 1d5a332 commit ed40323
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/core/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1835,25 +1835,28 @@ func DelMcisVm(nsId string, mcisId string, vmId string, option string) error {

fmt.Println("[Delete VM] " + vmId)

// ControlVm first
var wg sync.WaitGroup
results := make(chan ControlVmResult, 1)
wg.Add(1)
go ControlVmAsync(&wg, nsId, mcisId, vmId, ActionTerminate, results)
checkErr := <-results
wg.Wait()
close(results)
if checkErr.Error != nil {
common.CBLog.Info(checkErr.Error)
if option != "force" {
return checkErr.Error
// skip termination if option is force
if option != "force" {
// ControlVm first
var wg sync.WaitGroup
results := make(chan ControlVmResult, 1)
wg.Add(1)
go ControlVmAsync(&wg, nsId, mcisId, vmId, ActionTerminate, results)
checkErr := <-results
wg.Wait()
close(results)
if checkErr.Error != nil {
common.CBLog.Info(checkErr.Error)
if option != "force" {
return checkErr.Error
}
}
}
// for deletion, need to wait until termination is finished
// Sleep for 5 seconds
fmt.Printf("\n\n[Info] Sleep for 20 seconds for safe VM termination.\n\n")
time.Sleep(5 * time.Second)

// for deletion, need to wait until termination is finished
// Sleep for 5 seconds
fmt.Printf("\n\n[Info] Sleep for 20 seconds for safe VM termination.\n\n")
time.Sleep(5 * time.Second)
}

// get vm info
vmInfo, _ := GetVmObject(nsId, mcisId, vmId)
Expand Down

0 comments on commit ed40323

Please sign in to comment.