Skip to content

Commit

Permalink
cmd/osbuild-service-maintenance: respect dry run
Browse files Browse the repository at this point in the history
Respect dry run when terminating leftover SIs.
  • Loading branch information
croissanne committed Oct 28, 2024
1 parent 0ef0ae7 commit c1b6744
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/osbuild-service-maintenance/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ func AWSCleanup(maxConcurrentRequests int, dryRun bool, accessKeyID, accessKey s
}

instanceIDs := filterReservations(reservations)
err = a.TerminateInstances(instanceIDs)
if err != nil {
return fmt.Errorf("Unable to terminate secure instances: %w", err)
logrus.Infof("Cleaning up executor instances: %v", instanceIDs)
if !dryRun {
err = a.TerminateInstances(instanceIDs)
if err != nil {
return fmt.Errorf("Unable to terminate secure instances: %w", err)
}
} else {
logrus.Info("Dry run, didn't actually terminate any instances")
}
return nil
}
Expand Down

0 comments on commit c1b6744

Please sign in to comment.