Skip to content

Commit

Permalink
Fix flow reconcile ensure public ip release v.1.48 (#1036)
Browse files Browse the repository at this point in the history
* Fix flow reconcile ensure public ip

* Import order
  • Loading branch information
hebelsan authored Dec 10, 2024
1 parent bdb1cc0 commit 5983043
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/azure/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ const (
SeedAnnotationKeyUseFlow = AnnotationKeyUseFlow
// SeedAnnotationUseFlowValueNew is the value to restrict flow reconciliation to new shoot clusters
SeedAnnotationUseFlowValueNew = "new"

// CCMServiceTagKey is the service key applied for public IP tags.
CCMServiceTagKey = "k8s-azure-service"
// CCMLegacyServiceTagKey is the legacy service key applied for public IP tags.
CCMLegacyServiceTagKey = "service"
)

// UsernamePrefix is a constant for the username prefix of components deployed by Azure.
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/infrastructure/infraflow/ensurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/gardener/gardener-extension-provider-azure/pkg/apis/azure/helper"
"github.com/gardener/gardener-extension-provider-azure/pkg/apis/azure/v1alpha1"
"github.com/gardener/gardener-extension-provider-azure/pkg/azure"
"github.com/gardener/gardener-extension-provider-azure/pkg/azure/client"
"github.com/gardener/gardener-extension-provider-azure/pkg/controller/infrastructure/infraflow/shared"
"github.com/gardener/gardener-extension-provider-azure/pkg/internal/infrastructure"
Expand Down Expand Up @@ -371,7 +372,8 @@ func (fctx *FlowContext) ensurePublicIps(ctx context.Context) error {
}
currentIPs = Filter(currentIPs, func(address *armnetwork.PublicIPAddress) bool {
// filter only these IpConfigs prefixed by the cluster name and that do not contain the CCM tags.
return fctx.adapter.HasShootPrefix(address.Name) && address.Tags["k8s-azure-service"] == nil
return fctx.adapter.HasShootPrefix(address.Name) &&
(address.Tags[azure.CCMServiceTagKey] == nil && address.Tags[azure.CCMLegacyServiceTagKey] == nil)
})
// obtain an indexed list of current IPs
nameToCurrentIps := ToMap(currentIPs, func(t *armnetwork.PublicIPAddress) string {
Expand Down Expand Up @@ -412,8 +414,9 @@ func (fctx *FlowContext) ensurePublicIps(ctx context.Context) error {
err := fctx.providerAccess.DeletePublicIP(ctx, fctx.adapter.ResourceGroupName(), ipName)
if err != nil {
joinError = errors.Join(joinError, err)
} else {
fctx.inventory.Delete(ip)
}
fctx.inventory.Delete(ip)
}

if joinError != nil {
Expand Down

0 comments on commit 5983043

Please sign in to comment.