Skip to content

Commit

Permalink
fix retry variable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisonB319 committed Mar 20, 2024
1 parent d3cc05d commit bfda3cc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions e2e/vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ const (
maxRetries = 3
)

type VMSSOperationRetrier struct {
maxRetries int
}

func bootstrapVMSS(ctx context.Context, t *testing.T, r *mrand.Rand, vmssName string, opts *scenarioRunOpts, publicKeyBytes []byte) (*armcompute.VirtualMachineScaleSet, func(), error) {
nodeBootstrapping, err := getNodeBootstrapping(ctx, opts.nbc)
if err != nil {
Expand All @@ -49,16 +45,15 @@ func bootstrapVMSS(ctx context.Context, t *testing.T, r *mrand.Rand, vmssName st
log.Printf("finished deleting vmss %q", vmssName)
}

rOpts := VMSSOperationRetrier{maxRetries: maxRetries}
vmssModel, err := rOpts.createVMSSWithPayload(ctx, nodeBootstrapping.CustomData, nodeBootstrapping.CSE, vmssName, publicKeyBytes, opts)
vmssModel, err := createVMSSWithPayload(ctx, nodeBootstrapping.CustomData, nodeBootstrapping.CSE, vmssName, publicKeyBytes, opts)
if err != nil {
return nil, cleanupVMSS, fmt.Errorf("unable to create VMSS with payload: %w", err)
}

return vmssModel, cleanupVMSS, nil
}

func (r VMSSOperationRetrier) createVMSSWithPayload(ctx context.Context, customData, cseCmd, vmssName string, publicKeyBytes []byte, opts *scenarioRunOpts) (*armcompute.VirtualMachineScaleSet, error) {
func createVMSSWithPayload(ctx context.Context, customData, cseCmd, vmssName string, publicKeyBytes []byte, opts *scenarioRunOpts) (*armcompute.VirtualMachineScaleSet, error) {
model := getBaseVMSSModel(vmssName, string(publicKeyBytes), customData, cseCmd, opts)

if opts.suiteConfig.BuildID != "" {
Expand All @@ -85,7 +80,8 @@ func (r VMSSOperationRetrier) createVMSSWithPayload(ctx context.Context, customD

var pollErr error
var vmssResp *armcompute.VirtualMachineScaleSetsClientCreateOrUpdateResponse
for i := 0; i < r.maxRetries; i++ {

for i := 0; i < maxRetries; i++ {
createVMSSCtx, cancel := context.WithTimeout(ctx, vmssClientCreateVMSSPollingTimeout)
defer cancel()

Expand All @@ -107,7 +103,7 @@ func (r VMSSOperationRetrier) createVMSSWithPayload(ctx context.Context, customD
if pollErr == nil {
return &vmssResp.VirtualMachineScaleSet, nil
} else {
log.Printf("failed to create VMSS. Retry attempts left: %d", r.maxRetries-(i+1))
log.Printf("failed to create VMSS. Retry attempts left: %d", maxRetries-(i+1))
}
}
return nil, fmt.Errorf("unable to create VMSS %q: %w", vmssName, pollErr)
Expand Down

0 comments on commit bfda3cc

Please sign in to comment.