Skip to content

Commit

Permalink
pkg/asset/cluster: tectonicClusterID or kubernetes.io/cluster/<name> …
Browse files Browse the repository at this point in the history
…deletion

We're having trouble getting our resources tagged consistently, with
elastic IPs, NAT gateways, etc. missing kubernetes.io/cluster/<name>
[1].  Meanwhile, the ingress operator will be creating elastic load
balancers that lack tectonicClusterID [2].  This change deletes
everything we can find with either tag while we sort out something
cleaner.

[1]: #458 (comment)
[2]: #458 (comment)
  • Loading branch information
wking committed Oct 25, 2018
1 parent cd1fe26 commit 6e1b19a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions pkg/asset/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {
case installConfig.Config.Platform.AWS != nil:
metadata.ClusterPlatformMetadata.AWS = &types.ClusterAWSPlatformMetadata{
Region: installConfig.Config.Platform.AWS.Region,
Identifier: map[string]string{
"tectonicClusterID": installConfig.Config.ClusterID,
Identifier: []map[string]string{
{
"tectonicClusterID": installConfig.Config.ClusterID,
},
{
fmt.Sprintf("kubernetes.io/cluster/%s", installConfig.Config.ObjectMeta.Name): "owned",
},
},
}
case installConfig.Config.Platform.OpenStack != nil:
Expand Down
7 changes: 6 additions & 1 deletion pkg/destroy/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import (

// NewAWS returns an AWS destroyer from ClusterMetadata.
func NewAWS(logger logrus.FieldLogger, metadata *types.ClusterMetadata) (Destroyer, error) {
filters := make([]atd.AWSFilter, 0, len(metadata.ClusterPlatformMetadata.AWS.Identifier))
for _, filter := range metadata.ClusterPlatformMetadata.AWS.Identifier {
filters = append(filters, filter)
}

return &atd.ClusterUninstaller{
Filters: metadata.ClusterPlatformMetadata.AWS.Identifier,
Filters: filters,
Region: metadata.ClusterPlatformMetadata.AWS.Region,
ClusterName: metadata.ClusterName,
Logger: logger,
Expand Down
8 changes: 6 additions & 2 deletions pkg/types/clustermetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ func (cpm *ClusterPlatformMetadata) Platform() string {
// ClusterAWSPlatformMetadata contains AWS metadata.
type ClusterAWSPlatformMetadata struct {
Region string `json:"region"`
// Most AWS resources are tagged with these tags as identifier.
Identifier map[string]string `json:"identifier"`

// Identifier holds a slice of filter maps. The maps hold the
// key/value pairs for the tags we will be matching against. A
// resource matches the map if all of the key/value pairs are in its
// tags. A resource matches Identifier if it matches any of the maps.
Identifier []map[string]string `json:"identifier"`
}

// ClusterOpenStackPlatformMetadata contains OpenStack metadata.
Expand Down

0 comments on commit 6e1b19a

Please sign in to comment.