From 07c1f3b2f8df69cc2a65628f8d28159c8e1f8f22 Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Wed, 3 Aug 2022 11:17:19 +0300 Subject: [PATCH] worker: fix crash if no autoscale instance is defined The worker assumes that when running on AWS an autoscale is defined. If not defined, the worker crashes --- cmd/osbuild-worker/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/osbuild-worker/main.go b/cmd/osbuild-worker/main.go index 552383147..d5e6c94c5 100644 --- a/cmd/osbuild-worker/main.go +++ b/cmd/osbuild-worker/main.go @@ -128,6 +128,10 @@ func setProtection(protected bool) { } return } + if len(asInstanceOutput.AutoScalingInstances) == 0 { + logrus.Info("No Autoscaling instace is defined") + return + } // make the request to protect (or unprotect) the instance input := &autoscaling.SetInstanceProtectionInput{