From c1b67440c4056baa3ac874d9992ead6baa8d1f60 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Wed, 23 Oct 2024 10:36:53 +0200 Subject: [PATCH] cmd/osbuild-service-maintenance: respect dry run Respect dry run when terminating leftover SIs. --- cmd/osbuild-service-maintenance/aws.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/osbuild-service-maintenance/aws.go b/cmd/osbuild-service-maintenance/aws.go index ea88033e1..29c8402da 100644 --- a/cmd/osbuild-service-maintenance/aws.go +++ b/cmd/osbuild-service-maintenance/aws.go @@ -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 }