cmd/osbuild-service-maintenance: respect dry run

Respect dry run when terminating leftover SIs.
This commit is contained in:
Sanne Raymaekers 2024-10-23 10:36:53 +02:00
parent 0ef0ae7c97
commit c1b67440c4

View file

@ -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
}