mirror of https://github.com/kubernetes/kops.git
pkg/resources/aws:simplify code and remove code
This commit is contained in:
commit
dffc8975d6
|
@ -8,9 +8,6 @@ dnsprovider/pkg/dnsprovider/providers/google/clouddns/internal/stubs
|
|||
node-authorizer/pkg/authorizers/aws
|
||||
node-authorizer/pkg/server
|
||||
pkg/resources/ali
|
||||
pkg/resources/aws
|
||||
pkg/resources/digitalocean
|
||||
pkg/resources/digitalocean/dns
|
||||
pkg/resources/openstack
|
||||
pkg/sshcredentials
|
||||
upup/pkg/fi
|
||||
|
|
|
@ -17,8 +17,6 @@ limitations under the License.
|
|||
package aws
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
@ -1361,54 +1359,6 @@ func FindNatGateways(cloud fi.Cloud, routeTables map[string]*resources.Resource,
|
|||
return resourceTrackers, nil
|
||||
}
|
||||
|
||||
// extractClusterName performs string-matching / parsing to determine the ClusterName in some instance-data
|
||||
// It returns "" if it could not be (uniquely) determined
|
||||
func extractClusterName(userData string) string {
|
||||
clusterName := ""
|
||||
|
||||
scanner := bufio.NewScanner(bytes.NewReader([]byte(userData)))
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
if strings.HasPrefix(line, "INSTANCE_PREFIX:") {
|
||||
// kube-up
|
||||
// Match:
|
||||
// INSTANCE_PREFIX: 'clustername'
|
||||
// INSTANCE_PREFIX: "clustername"
|
||||
// INSTANCE_PREFIX: clustername
|
||||
line = strings.TrimPrefix(line, "INSTANCE_PREFIX:")
|
||||
} else if strings.HasPrefix(line, "ClusterName:") {
|
||||
// kops
|
||||
// Match:
|
||||
// ClusterName: 'clustername'
|
||||
// ClusterName: "clustername"
|
||||
// ClusterName: clustername
|
||||
line = strings.TrimPrefix(line, "ClusterName:")
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
line = strings.TrimSpace(line)
|
||||
line = strings.Trim(line, "'\"")
|
||||
if clusterName != "" && clusterName != line {
|
||||
klog.Warningf("cannot uniquely determine cluster-name, found %q and %q", line, clusterName)
|
||||
return ""
|
||||
}
|
||||
clusterName = line
|
||||
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
klog.Warningf("error scanning UserData: %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return clusterName
|
||||
|
||||
}
|
||||
|
||||
// DeleteAutoScalingGroupLaunchTemplate deletes
|
||||
func DeleteAutoScalingGroupLaunchTemplate(cloud fi.Cloud, r *resources.Resource) error {
|
||||
c, ok := cloud.(awsup.AWSCloud)
|
||||
|
|
|
@ -55,8 +55,6 @@ type Cloud struct {
|
|||
|
||||
// RegionName holds the region, renamed to avoid conflict with Region()
|
||||
RegionName string
|
||||
|
||||
tags map[string]string
|
||||
}
|
||||
|
||||
var _ fi.Cloud = &Cloud{}
|
||||
|
|
|
@ -504,16 +504,6 @@ func createRecord(c *godo.Client, zoneName string, createRequest *godo.DomainRec
|
|||
return nil
|
||||
}
|
||||
|
||||
// editRecord edits a record given an associated zone and a godo.DomainRecordEditRequest
|
||||
func editRecord(c *godo.Client, zoneName string, recordID int, editRequest *godo.DomainRecordEditRequest) error {
|
||||
_, _, err := c.Domains.EditRecord(context.TODO(), zoneName, recordID, editRequest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error editing record: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// deleteRecord deletes a record given an associated zone and a record ID
|
||||
func deleteRecord(c *godo.Client, zoneName string, recordID int) error {
|
||||
_, err := c.Domains.DeleteRecord(context.TODO(), zoneName, recordID)
|
||||
|
|
|
@ -317,12 +317,13 @@ func deleteRecord(cloud fi.Cloud, domain string, t *resources.Resource) error {
|
|||
|
||||
func waitForDetach(cloud *Cloud, action *godo.Action) error {
|
||||
timeout := time.After(10 * time.Second)
|
||||
tick := time.Tick(500 * time.Millisecond)
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
return errors.New("timed out waiting for volume to detach")
|
||||
case <-tick:
|
||||
case <-ticker.C:
|
||||
updatedAction, _, err := cloud.Client.Actions.Get(context.TODO(), action.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue