Merge pull request #13907 from hakman/gce_fix_cleanup_by_hash

Fix cleanup of firewall rules that contain targets with the cluster name hash
This commit is contained in:
Kubernetes Prow Robot 2022-06-29 02:50:06 -07:00 committed by GitHub
commit 36aa0920df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -540,7 +540,7 @@ nextFirewallRule:
// We consider only firewall rules that target our cluster tags, which include the cluster name or hash
tagPrefix := gce.SafeClusterName(d.clusterName) + "-"
clusterNameHash := truncate.HashString(d.clusterName, 6)
clusterNameHash := truncate.HashString(gce.SafeClusterName(d.clusterName), 6)
if len(firewallRule.TargetTags) != 0 {
tagMatchCount := 0
for _, target := range firewallRule.TargetTags {
@ -1241,12 +1241,9 @@ func (d *clusterDiscoveryGCE) matchesClusterNameMultipart(name string, maxParts
}
safeName := gce.SafeObjectName(id, d.clusterName)
suffixedName, err := gce.ClusterSuffixedName(id, d.clusterName, 63)
if err != nil {
return false
}
clusterNameHash := truncate.HashString(gce.SafeClusterName(d.clusterName), 6)
if name == safeName || name == suffixedName {
if name == safeName || strings.Contains(name, clusterNameHash) {
return true
}
}