osbuild-service-maintenance/aws: avoid error on empty list
Passing an empty list to `TerminateInstances` causes an error message, which is not necessary, as there is nothing to terminate.
This commit is contained in:
parent
24e256c225
commit
87ef1527fc
1 changed files with 5 additions and 3 deletions
|
|
@ -158,9 +158,11 @@ func terminateOrphanedSecureInstances(a *awscloud.AWS, dryRun bool) error {
|
|||
instanceIDs = filterOnTooOld(instanceIDs, reservations)
|
||||
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)
|
||||
if len(instanceIDs) > 0 {
|
||||
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue