Skip to content

Commit

Permalink
Increase waiting time to reduce call when waiting target status
Browse files Browse the repository at this point in the history
  • Loading branch information
powerkimhub committed Oct 24, 2024
1 parent ca3d441 commit e9c2f35
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions api-runtime/common-runtime/VMManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func StartVM(connectionName string, rsType string, reqInfo cres.VMReqInfo, IDTra
MSG string
}

waiter := NewWaiter(5, 240) // (sleep, timeout)
waiter := NewWaiter(15, 600) // (sleep, timeout)
var publicIP string
for {
vmInfo, err := handler.GetVM(info.IId)
Expand Down Expand Up @@ -1657,7 +1657,7 @@ func DeleteVM(connectionName string, rsType string, nameID string, force string)
}

// Check Sync Called
waiter := NewWaiter(5, 600) // (sleep, timeout)
waiter := NewWaiter(15, 600) // (sleep, timeout)

for {
status, err := handler.(cres.VMHandler).GetVMStatus(driverIId)
Expand Down
22 changes: 11 additions & 11 deletions cloud-control-manager/cloud-driver/drivers/aws/profile/CallCount.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ import (

var cblog = cblogger.GetLogger("CLOUD-BARISTA")

var apiCallCount int
var mutex sync.Mutex
var AWSAPICallCount int
var AWSMutex sync.Mutex

func incrementCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount++
AWSMutex.Lock()
defer AWSMutex.Unlock()
AWSAPICallCount++
}

func ResetCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount = 0
AWSMutex.Lock()
defer AWSMutex.Unlock()
AWSAPICallCount = 0
}

func GetCallCount() int {
mutex.Lock()
defer mutex.Unlock()
return apiCallCount
AWSMutex.Lock()
defer AWSMutex.Unlock()
return AWSAPICallCount
}

// creates a new AWS session that counts the number of API calls made
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import (

var cblog = cblogger.GetLogger("CLOUD-BARISTA")

var apiCallCount int
var mutex sync.Mutex
var azureAPICallCount int
var azureMutex sync.Mutex

func incrementCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount++
azureMutex.Lock()
defer azureMutex.Unlock()
azureAPICallCount++
}

func ResetCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount = 0
azureMutex.Lock()
defer azureMutex.Unlock()
azureAPICallCount = 0
}

func GetCallCount() int {
mutex.Lock()
defer mutex.Unlock()
return apiCallCount
azureMutex.Lock()
defer azureMutex.Unlock()
return azureAPICallCount
}

// NewCountingPolicy creates a new custom policy to count Azure SDK API calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (vmHandler *AzureVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, e
return irs.VMInfo{}, createErr
}
curRetryCnt := 0
maxRetryCnt := 120
maxRetryCnt := 40 // 15sec * 40 = 10min
// 5. Wait Running
for {
resp, _ := vmHandler.Client.InstanceView(vmHandler.Ctx, vmHandler.Region.Region, vmReqInfo.IId.NameId, nil)
Expand All @@ -459,7 +459,7 @@ func (vmHandler *AzureVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, e
break
}
curRetryCnt++
time.Sleep(1 * time.Second)
time.Sleep(15 * time.Second)
if curRetryCnt > maxRetryCnt {
createErr := errors.New(fmt.Sprintf("Failed to Start VM. exceeded maximum retry count %d and Finished to rollback deleting", maxRetryCnt))
cleanErr := vmHandler.cleanDeleteVm(vmReqInfo.IId)
Expand Down Expand Up @@ -1405,7 +1405,7 @@ type CleanVMClientSet struct {
// VMCleanRelatedResource
func (vmHandler *AzureVMHandler) cleanVMRelatedResource(cleanRelatedResource VMCleanRelatedResource) (bool, error) {
curRetryCnt := 0
maxRetryCnt := 120
maxRetryCnt := 40 // 15sec * 40 = 10min (Total waiting time for deletion of related resources)

networkInterfaceName := cleanRelatedResource.CleanTargetResource.NetworkInterfaceName
publicIPId := cleanRelatedResource.CleanTargetResource.PublicIPName
Expand Down Expand Up @@ -1445,7 +1445,7 @@ func (vmHandler *AzureVMHandler) cleanVMRelatedResource(cleanRelatedResource VMC
}

curRetryCnt++
time.Sleep(1 * time.Second)
time.Sleep(15 * time.Second)
if curRetryCnt > maxRetryCnt {
createErr := errors.New(fmt.Sprintf("Failed to clean remained vnic ("+networkInterfaceName+"). exceeded maximum retry count %d", maxRetryCnt))
cblogger.Warn(createErr.Error())
Expand Down Expand Up @@ -1477,7 +1477,7 @@ func (vmHandler *AzureVMHandler) cleanVMRelatedResource(cleanRelatedResource VMC
}

curRetryCnt++
time.Sleep(1 * time.Second)
time.Sleep(15 * time.Second)
if curRetryCnt > maxRetryCnt {
createErr := errors.New(fmt.Sprintf("Failed to clean remained public IP ("+publicIPId+"). exceeded maximum retry count %d", maxRetryCnt))
cblogger.Warn(createErr.Error())
Expand Down Expand Up @@ -1505,7 +1505,7 @@ func (vmHandler *AzureVMHandler) cleanVMRelatedResource(cleanRelatedResource VMC
}

curRetryCnt++
time.Sleep(1 * time.Second)
time.Sleep(15 * time.Second)
if curRetryCnt > maxRetryCnt {
createErr := errors.New(fmt.Sprintf("Failed to clean remained disk ("+vmDiskId+"). exceeded maximum retry count %d", maxRetryCnt))
cblogger.Warn(createErr.Error())
Expand Down
22 changes: 11 additions & 11 deletions cloud-control-manager/cloud-driver/drivers/gcp/profile/CallCount.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import (
"golang.org/x/oauth2"
)

var apiCallCount int
var mutex sync.Mutex
var GCPAPICallCount int
var GCPMutex sync.Mutex

// incrementCallCount increments the count of API calls.
func incrementCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount++
GCPMutex.Lock()
defer GCPMutex.Unlock()
GCPAPICallCount++
}

// ResetCallCount resets the API call count.
func ResetCallCount() {
mutex.Lock()
defer mutex.Unlock()
apiCallCount = 0
GCPMutex.Lock()
defer GCPMutex.Unlock()
GCPAPICallCount = 0
}

// GetCallCount returns the current count of API calls.
func GetCallCount() int {
mutex.Lock()
defer mutex.Unlock()
return apiCallCount
GCPMutex.Lock()
defer GCPMutex.Unlock()
return GCPAPICallCount
}

// NewCountingClient returns an *http.Client that counts each request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, err
}
break
}
time.Sleep(5 * time.Second)
time.Sleep(15 * time.Second)
}

/*
Expand Down Expand Up @@ -1318,7 +1318,7 @@ func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) {
// Suspending 되도록 3초 정도 대기 함.
//===================================
curRetryCnt := 0
maxRetryCnt := 120
maxRetryCnt := 40 // 15sec * 40 = 600sec = 10min
for {
curStatus, errStatus := vmHandler.GetVMStatus(vmIID)
if errStatus != nil {
Expand All @@ -1334,7 +1334,7 @@ func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error) {
//if curStatus != irs.VMStatus(waitStatus) {
curRetryCnt++
cblogger.Debugf("The VM status is not [%s], so waiting for 1 second before querying.", waitStatus)
time.Sleep(time.Second * 1)
time.Sleep(time.Second * 15)
if curRetryCnt > maxRetryCnt {
cblogger.Errorf("Forcibly stopping after waiting for a long time (%d seconds) as the VM's Status value hasn't changed to [%s].", maxRetryCnt, waitStatus)
return irs.VMStatus("Failed"), errors.New("Stopped waiting after waiting for a long time, but the status of the created VM did not change to [" + waitStatus + "].")
Expand Down

0 comments on commit e9c2f35

Please sign in to comment.