Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix force refine and delete option #1394

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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