From 72f936e956a5f3778ec6cb2d3f47fed9df192bb2 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Thu, 24 Oct 2019 12:50:30 -0400 Subject: [PATCH] [aws] use simple string prefix placeholder match Addresses a [comment on PR2235](https://github.com/kubernetes/autoscaler/pull/2235/files#r313536379) to remove the unnecessary use of a regex with a simpler string prefix matching for placeholder names. --- cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go index 8acffeae69e6..b0e55e1fc036 100644 --- a/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go +++ b/cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go @@ -19,7 +19,6 @@ package aws import ( "fmt" "reflect" - "regexp" "strings" "sync" @@ -287,8 +286,7 @@ func (m *asgCache) DeleteInstances(instances []*AwsInstanceRef) error { // isPlaceholderInstance checks if the given instance is only a placeholder func (m *asgCache) isPlaceholderInstance(instance *AwsInstanceRef) bool { - matched, _ := regexp.MatchString(fmt.Sprintf("^%s.*\\d+$", placeholderInstanceNamePrefix), instance.Name) - return matched + return strings.HasPrefix(instance.Name, placeholderInstanceNamePrefix) } // Fetch automatically discovered ASGs. These ASGs should be unregistered if