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

[NCP Classic/VPC] Update for VM Status check when running GetVM() and ListVM(), Apply Updated Parameter Return Values on VMImage/MyImage #1244

Merged
merged 12 commits into from
Jul 27, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,11 @@ func (vmHandler *NcpVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) {

// Since it's impossible to get VM info. during Creation, ...
switch string(curStatus) {
case "Creating", "Booting":
case "Creating":
cblogger.Infof("Wait for the VM creation before inquiring VM info. The VM status : [%s]", string(curStatus))
return irs.VMInfo{}, errors.New("The VM status is 'Creating' or 'Booting', wait for the VM creation before inquiring VM info. : " + vmIID.SystemId)
return irs.VMInfo{}, errors.New("The VM status is 'Creating', wait for the VM creation before inquiring VM info. : " + vmIID.SystemId)
default:
cblogger.Infof("===> The VM status not 'Creating' or 'Booting', you can get the VM info.")
cblogger.Infof("===> The VM status not 'Creating', you can get the VM info.")
}

regionNo, err := vmHandler.GetRegionNo(vmHandler.RegionInfo.Region)
Expand Down Expand Up @@ -969,7 +969,7 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) {
//Caution!!
resultStatus = "Booting"
} else if strings.EqualFold(vmStatus, "setting up") {
resultStatus = "Creating"
resultStatus = "Setting_up"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@innodreamer


  • 현재 반환 상태 값 Setting_up은,
  • 다음 GetVMStatus()와 같이 Spider 서버로 반환하는 VM 상태로 직접 반환 되고 있습니다.

vmStatus, statusErr := ConvertVMStatusString(*result.ServerInstanceList[0].ServerInstanceStatusName)

} else if strings.EqualFold(vmStatus, "running") {
resultStatus = "Running"
} else if strings.EqualFold(vmStatus, "shutting down") {
Expand Down Expand Up @@ -1136,29 +1136,23 @@ func (vmHandler *NcpVMHandler) ListVM() ([]*irs.VMInfo, error) {
cblogger.Debug(newErr.Error())
return nil, nil // Not returns Error message
} else {
cblogger.Info("Succeeded in Getting ServerInstanceList!!")
cblogger.Info("Succeeded in Getting ServerInstanceList from NCP!!")
}

var vmInfoList []*irs.VMInfo
for _, vm := range result.ServerInstanceList {
cblogger.Info("NCP VM Instance Info. inquiry : ", *vm.ServerInstanceNo)

curStatus, errStatus := vmHandler.GetVMStatus(irs.IID{SystemId: *vm.ServerInstanceNo})
if errStatus != nil {
rtnErr := logAndReturnError(callLogInfo, "Failed to Get the VM Status : ", errStatus)
return nil, rtnErr
curStatus, statusErr := vmHandler.GetVMStatus(irs.IID{SystemId: *vm.ServerInstanceNo})
if statusErr != nil {
newErr := fmt.Errorf("Failed to Get the Status of VM : [%s], [%v]", *vm.ServerInstanceNo, statusErr.Error())
cblogger.Error(newErr.Error())
return nil, newErr
} else {
cblogger.Infof("Succeeded to Get the VM Status of [%s] : [%s]", irs.IID{SystemId: *vm.ServerInstanceNo}, curStatus)
cblogger.Infof("Succeeded to Get the Status of VM [%s] : [%s]", *vm.ServerInstanceNo, string(curStatus))
}
cblogger.Info("===> VM Status : ", curStatus)
cblogger.Infof("===> VM Status : [%s]", string(curStatus))

switch string(curStatus) {
case "Creating", "Booting":
cblogger.Errorf("The VM status : [%s], Can Not Get the VM info.", string(curStatus))
return nil, nil

default:
cblogger.Infof("===> The VM status not 'Creating' or 'Booting', you can get the VM info.")
if (string(curStatus) != "Creating") && (string(curStatus) != "Terminating") {
cblogger.Infof("===> The VM Status not 'Creating' or 'Terminating', you can get the VM info.")
vmInfo, error := vmHandler.GetVM(irs.IID{SystemId: *vm.ServerInstanceNo})
if error != nil {
cblogger.Error(error.Error())
Expand Down Expand Up @@ -1189,9 +1183,9 @@ func (vmHandler *NcpVMHandler) WaitToGetInfo(vmIID irs.IID) (irs.VMStatus, error
cblogger.Infof("===> VM Status : [%s]", curStatus)

switch string(curStatus) {
case "Creating", "Booting":
case "Creating", "Booting", "Setting_up":
curRetryCnt++
cblogger.Infof("The VM is still 'Creating', so wait for a second more before inquiring the VM info.")
cblogger.Infof("The VM is still 'Creating' and 'Booting', so wait for a second more before inquiring the VM info.")
time.Sleep(time.Second * 5)
if curRetryCnt > maxRetryCnt {
cblogger.Errorf("Despite waiting for a long time(%d sec), the VM status is %s, so it is forcibly finishied.", maxRetryCnt, curStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func init() {
func (vmHandler *NcpVpcVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error) {
cblogger.Info("NCPVPC Cloud driver: called StartVM()!!")
InitLog()
callLogInfo := GetCallLogScheme(vmHandler.CredentialInfo.ClientId, call.VM, vmReqInfo.IId.NameId, "StartVM()")
callLogInfo := GetCallLogScheme(vmHandler.RegionInfo.Region, call.VM, vmReqInfo.IId.NameId, "StartVM()")

if strings.EqualFold(vmReqInfo.IId.NameId, "") {
newErr := fmt.Errorf("Invalid VM Name required")
Expand Down Expand Up @@ -334,11 +334,11 @@ func (vmHandler *NcpVpcVMHandler) GetVM(vmIID irs.IID) (irs.VMInfo, error) {

// Since it's impossible to get VM info. during Creation, ...
switch string(curStatus) {
case "Creating", "Booting":
case "Creating":
cblogger.Infof("The VM status is '%s', so wait for the VM creation before inquiring the info.", string(curStatus))
return irs.VMInfo{}, errors.New("The VM status is 'Creating' or 'Booting', so wait for the VM creation before inquiring the info. : " + vmIID.SystemId)
return irs.VMInfo{}, errors.New("The VM status is 'Creating', so wait for the VM creation before inquiring the info. : " + vmIID.SystemId)
default:
cblogger.Infof("===> The VM status is not 'Creating' or 'Booting', you can get the VM info.")
cblogger.Infof("===> The VM status is not 'Creating', you can get the VM info.")
}

/*
Expand Down Expand Up @@ -776,7 +776,7 @@ func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error) {
//Caution!!
resultStatus = "Booting"
} else if strings.EqualFold(vmStatus, "setting up") {
resultStatus = "Creating"
resultStatus = "Setting_up"
} else if strings.EqualFold(vmStatus, "running") {
resultStatus = "Running"
} else if strings.EqualFold(vmStatus, "shutting down") {
Expand Down Expand Up @@ -901,36 +901,30 @@ func (vmHandler *NcpVpcVMHandler) ListVM() ([]*irs.VMInfo, error) {
return nil, newErr
}
LoggingInfo(callLogInfo, callLogStart)
cblogger.Info("Succeeded in Getting ServerInstanceList from NCP VPC!!")
cblogger.Info("Succeeded in Getting ServerInstanceList from NCP!!")

var vmInfoList []*irs.VMInfo
for _, vm := range result.ServerInstanceList {
cblogger.Infof("Inquiry of NCP VM Instance info : [%s]", *vm.ServerInstanceNo)

curStatus, statusErr := vmHandler.GetVMStatus(irs.IID{SystemId: *vm.ServerInstanceNo})
if statusErr != nil {
cblogger.Errorf("Failed to Get the VM Status of VM : [%s]", *vm.ServerInstanceNo)
cblogger.Error(statusErr.Error())
newErr := fmt.Errorf("Failed to Get the Status of VM : [%s], [%v]", *vm.ServerInstanceNo, statusErr.Error())
cblogger.Error(newErr.Error())
return nil, newErr
} else {
cblogger.Infof("Succeed in Getting the VM Status of [%s] : [%s]", *vm.ServerInstanceNo, curStatus)
cblogger.Infof("Succeeded in Getting the Status of VM [%s] : [%s]", *vm.ServerInstanceNo, string(curStatus))
}
cblogger.Infof("===> VM Status : [%s]", curStatus)

switch string(curStatus) {
case "Creating", "Booting":
return []*irs.VMInfo{}, nil
cblogger.Infof("===> VM Status : [%s]", string(curStatus))

default:
cblogger.Infof("===> The VM status not 'Creating' or 'Booting', you can get the VM info.")
if (string(curStatus) != "Creating") && (string(curStatus) != "Terminating") {
cblogger.Infof("===> The VM Status not 'Creating' or 'Terminating', you can get the VM info.")
vmInfo, error := vmHandler.GetVM(irs.IID{SystemId: *vm.ServerInstanceNo})
if error != nil {
cblogger.Error(error.Error())
return []*irs.VMInfo{}, error
return nil, error
}
vmInfoList = append(vmInfoList, &vmInfo)
}
}

return vmInfoList, nil
}

Expand Down Expand Up @@ -1349,9 +1343,9 @@ func (vmHandler *NcpVpcVMHandler) WaitToGetInfo(vmIID irs.IID) (irs.VMStatus, er
cblogger.Infof("===> VM Status : [%s]", curStatus)

switch string(curStatus) {
case "Creating", "Booting":
case "Creating", "Booting", "Setting_up":
Copy link
Member Author

@innodreamer innodreamer Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@powerkimhub
VM 생성시간 동안 waiting 할때 'Setting_up' 상태일때도 waiting 하도록 코드에 반영된 상태입니다.
그리고, disk detach 할때도 spider server에서 VM 상태를 check 할때 'Setting_up' 단계에서 오류가 발생하는지 여부도 테스트된 상태입니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@innodreamer



  • 가능한 시나리오라고 하면,

  • GetVMStatus() 뿐만 아니라, ConvertVMStatusString()를 활용하는 Driver API 중

    • 서버 쪽으로 제공되는 반환 값에 Setting_up 상태가 포함될 여지는 없는 지 함께 확인 부탁드립니다.
  • 아울러, ConvertVMStatusString()의 경우,

    • VMHandler.go 내부에서만 사용되오니, convertVMStatusString()로 수정해 두는 것이 좋을 듯합니다.

curRetryCnt++
cblogger.Infof("The VM is 'Creating', so wait for a second more before inquiring the VM info.")
cblogger.Infof("The VM is 'Creating' and 'Booting', so wait for a second more before inquiring the VM info.")
time.Sleep(time.Second * 5)
if curRetryCnt > maxRetryCnt {
cblogger.Errorf("Despite waiting for a long time(%d sec), the VM status is '%s', so it is forcibly finishied.", maxRetryCnt, curStatus)
Expand Down