aws: Skip WarmPool checks when it's not enabled

This commit is contained in:
Ciprian Hacman 2024-01-04 05:00:05 +02:00 committed by Peter Rifel
parent 349de70cda
commit 771a3fb256
No known key found for this signature in database
1 changed files with 11 additions and 3 deletions

View File

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