AWS: Remove getInstancesByRegex (dead code)

Fix #47409
pull/6/head
Justin Santa Barbara 2017-06-13 03:47:50 -04:00
parent 85832892b1
commit b87c4398c7
1 changed files with 0 additions and 51 deletions

View File

@ -21,7 +21,6 @@ import (
"fmt"
"io"
"net"
"regexp"
"strconv"
"strings"
"sync"
@ -1109,56 +1108,6 @@ func (c *Cloud) InstanceType(nodeName types.NodeName) (string, error) {
return aws.StringValue(inst.InstanceType), nil
}
// Return a list of instances matching regex string.
func (c *Cloud) getInstancesByRegex(regex string) ([]types.NodeName, error) {
filters := []*ec2.Filter{newEc2Filter("instance-state-name", "running")}
instances, err := c.describeInstances(filters)
if err != nil {
return []types.NodeName{}, err
}
if len(instances) == 0 {
return []types.NodeName{}, fmt.Errorf("no instances returned")
}
if strings.HasPrefix(regex, "'") && strings.HasSuffix(regex, "'") {
glog.Infof("Stripping quotes around regex (%s)", regex)
regex = regex[1 : len(regex)-1]
}
re, err := regexp.Compile(regex)
if err != nil {
return []types.NodeName{}, err
}
matchingInstances := []types.NodeName{}
for _, instance := range instances {
// Only return fully-ready instances when listing instances
// (vs a query by name, where we will return it if we find it)
if orEmpty(instance.State.Name) == "pending" {
glog.V(2).Infof("Skipping EC2 instance (pending): %s", *instance.InstanceId)
continue
}
nodeName := mapInstanceToNodeName(instance)
if nodeName == "" {
glog.V(2).Infof("Skipping EC2 instance (no PrivateDNSName): %s",
aws.StringValue(instance.InstanceId))
continue
}
for _, tag := range instance.Tags {
if orEmpty(tag.Key) == "Name" && re.MatchString(orEmpty(tag.Value)) {
matchingInstances = append(matchingInstances, nodeName)
break
}
}
}
glog.V(2).Infof("Matched EC2 instances: %s", matchingInstances)
return matchingInstances, nil
}
// getCandidateZonesForDynamicVolume retrieves a list of all the zones in which nodes are running
// It currently involves querying all instances
func (c *Cloud) getCandidateZonesForDynamicVolume() (sets.String, error) {