Skip to content

Commit

Permalink
[aws] use simple string prefix placeholder match
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jaypipes committed Oct 24, 2019
1 parent 7118ea8 commit 72f936e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions cluster-autoscaler/cloudprovider/aws/auto_scaling_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package aws
import (
"fmt"
"reflect"
"regexp"
"strings"
"sync"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 72f936e

Please sign in to comment.