Skip to content

Commit

Permalink
Allow invalid state when updating compute env (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed Jan 3, 2024
1 parent 7129e70 commit 3482cb1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions hatchery/nextflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func createBatchComputeEnvironment(userName string, hostname string, tagsMap map
batchComputeEnvArn = *batchComputeEnv.ComputeEnvironments[0].ComputeEnvironmentArn

// wait for the compute env to be ready to be updated
err = waitForBatchComputeEnvironment(batchComputeEnvName, batchSvc)
err = waitForBatchComputeEnvironment(batchComputeEnvName, batchSvc, false)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -640,15 +640,15 @@ func createBatchComputeEnvironment(userName string, hostname string, tagsMap map
}

// the compute environment must be "VALID" before we can create the job queue: wait until ready
err = waitForBatchComputeEnvironment(batchComputeEnvName, batchSvc)
err = waitForBatchComputeEnvironment(batchComputeEnvName, batchSvc, true)
if err != nil {
return "", err
}

return batchComputeEnvArn, nil
}

func waitForBatchComputeEnvironment(batchComputeEnvName string, batchSvc *batch.Batch) error {
func waitForBatchComputeEnvironment(batchComputeEnvName string, batchSvc *batch.Batch, mustBeValid bool) error {
maxIter := 6
iterDelaySecs := 5
var compEnvStatus string
Expand All @@ -662,12 +662,17 @@ func waitForBatchComputeEnvironment(batchComputeEnvName string, batchSvc *batch.
return err
}
compEnvStatus = *batchComputeEnvs.ComputeEnvironments[0].Status
// possible statuses: CREATING | UPDATING | DELETING | DELETED | VALID | INVALID
if compEnvStatus == "VALID" {
Config.Logger.Print("Debug: Compute environment is ready")
break
}
if !mustBeValid && compEnvStatus == "INVALID" {
Config.Logger.Printf("Debug: Compute environment is %s and can't be used, but can be updated", compEnvStatus)
break
}
if i == maxIter {
return fmt.Errorf("Compute environment is not ready after %v seconds. Exiting", maxIter*iterDelaySecs)
return fmt.Errorf("compute environment is not ready after %v seconds. Exiting", maxIter*iterDelaySecs)
}
Config.Logger.Printf("Info: Compute environment is %s, waiting %vs and checking again", compEnvStatus, iterDelaySecs)
time.Sleep(time.Duration(iterDelaySecs) * time.Second)
Expand Down

0 comments on commit 3482cb1

Please sign in to comment.