Skip to content

Commit

Permalink
osbuild-service-maintenance/aws: avoid error on empty list
Browse files Browse the repository at this point in the history
Passing an empty list to `TerminateInstances` causes an
error message, which is not necessary, as there is
nothing to terminate.
  • Loading branch information
schuellerf committed Dec 5, 2024
1 parent cdfc21b commit ba65a81
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/osbuild-service-maintenance/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ba65a81

Please sign in to comment.