You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gce: Implement fine-grained resource-specific locking for L4 ILBs (#1088)
Introduces fine-grained resource-specific locking for internal load balancer (L4 ILB) GCE resources:
- Replaces the single global coarse-grained mutex (sharedResourceLock) with isolated, resource-scoped mutexes for Firewalls, HealthChecks, and InstanceGroups.
- Relocates the coarse-grained global lock acquisition to the top-level entry points of the ILB operations (ensureInternalLoadBalancer, updateInternalLoadBalancer, and ensureInternalLoadBalancerDeleted) when fine-grained locking is disabled.
- Refactors lockResourceIfShared to return a no-op unlock function when the fine-grained resource locking feature gate is disabled, preventing multi-level locking overhead and deadlock risks inside inner helpers.
- Includes comprehensive unit tests to verify proper isolation, lock scoping, and seamless fallback behavior when the feature gate is disabled.
Copy file name to clipboardExpand all lines: cmd/cloud-controller-manager/main.go
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,9 @@ var (
81
81
82
82
// enableGKETenantController enables the gke-tenant-controller-manager.
83
83
enableGKETenantControllerbool
84
+
85
+
// enableL4ILBFineGrainedLocks enables resource-specific locking for L4 ILB.
86
+
enableL4ILBFineGrainedLocksbool
84
87
)
85
88
86
89
funcmain() {
@@ -102,6 +105,7 @@ func main() {
102
105
cloudProviderFS.BoolVar(&enableL4DenyFirewall, "enable-l4-deny-firewall", false, "Enable creation and updates of Deny VPC Firewall Rules for L4 external load balancers. Requires --enable-pinhole and --enable-l4-deny-firewall-rollback-cleanup to be true.")
103
106
cloudProviderFS.BoolVar(&enableL4DenyFirewallRollbackCleanup, "enable-l4-deny-firewall-rollback-cleanup", false, "Enable cleanup codepath of the deny firewalls for rollback. The reason for it not being enabled by default is the additional GCE API calls that are made for checking if the deny firewalls exist/deletion which will eat up the quota unnecessarily.")
104
107
cloudProviderFS.BoolVar(&enableGKETenantController, "enable-gke-tenant-controller", false, "Enables the GKE Tenant Controller Manager for Multi-Tenancy.")
108
+
cloudProviderFS.BoolVar(&enableL4ILBFineGrainedLocks, "enable-l4-ilb-fine-grained-lock", false, "Enable resource-specific locking for L4 ILB")
Copy file name to clipboardExpand all lines: providers/gce/gce.go
+68Lines changed: 68 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -180,11 +180,14 @@ type Cloud struct {
180
180
// resources are only created in zones with active node capacity.
181
181
nodeZonesmap[string]sets.String
182
182
nodeInformerSynced cache.InformerSynced
183
+
183
184
// sharedResourceLock is used to serialize GCE operations that may mutate shared state to
184
185
// prevent inconsistencies. For example, load balancers manipulation methods will take the
185
186
// lock to prevent shared resources from being prematurely deleted while the operation is
186
187
// in progress.
187
188
sharedResourceLock sync.Mutex
189
+
// sharedResourceLocks is a concurrent map used for resource-specific fine-grained locking of shared resources (e.g. InstanceGroups, shared HealthChecks).
// If a new backend service was created, delete the old one.
325
324
ifexistingBackendService.Name!=expectedBSName {
326
325
klog.V(2).Infof("clearPreviousInternalResources(%v): expected backend service %q does not match previous %q - deleting backend service", loadBalancerName, expectedBSName, existingBackendService.Name)
klog.V(2).Infof("clearPreviousInternalResources(%v): expected health check %q does not match previous %q - deleting health check", loadBalancerName, expectedHCName, existingHCName)
klog.V(2).Infof("ensureInternalInstanceGroup(%v, %v): checking group that it contains %v nodes [node names limited, total number of nodes: %d], the following nodes have empty string in the zone field and won't be deleted: %v", name, zone, loggableNodeNames(nodes), len(nodes), loggableNodeNames(emptyZoneNodes))
0 commit comments