From 771a3fb25628f22941da2013f97011cd72f31967 Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Thu, 4 Jan 2024 05:00:05 +0200 Subject: [PATCH] aws: Skip WarmPool checks when it's not enabled --- upup/pkg/fi/nodeup/command.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/upup/pkg/fi/nodeup/command.go b/upup/pkg/fi/nodeup/command.go index db43d9949be15..3c04476ba68b5 100644 --- a/upup/pkg/fi/nodeup/command.go +++ b/upup/pkg/fi/nodeup/command.go @@ -246,9 +246,12 @@ func (c *NodeUpCommand) Run(out io.Writer) error { } modelContext.InstanceID = string(instanceIDBytes) - modelContext.ConfigurationMode, err = getAWSConfigurationMode(ctx, modelContext) - if err != nil { - return err + // Check if WarmPool is enabled first, to avoid additional API calls + if len(modelContext.NodeupConfig.WarmPoolImages) > 0 { + modelContext.ConfigurationMode, err = getAWSConfigurationMode(ctx, modelContext) + if err != nil { + return err + } } modelContext.MachineType, err = getMachineType() @@ -713,6 +716,11 @@ func getNodeConfigFromServers(ctx context.Context, bootConfig *nodeup.BootConfig } func getAWSConfigurationMode(ctx context.Context, c *model.NodeupModelContext) (string, error) { + // Check if WarmPool is enabled first, to avoid additional API calls + if len(c.NodeupConfig.WarmPoolImages) == 0 { + return "", nil + } + // Only worker nodes and apiservers can actually autoscale. // We are not adding describe permissions to the other roles role := c.BootConfig.InstanceGroupRole