Skip to content

Give resource lock acquisitions unique identities - #636

Merged
felix-kaestner merged 1 commit into
mainfrom
fix/resourcelock
Oct 14, 2026
Merged

felix-kaestner merged 1 commit into
mainfrom
fix/resourcelock

Conversation

@felix-kaestner

Copy link
Copy Markdown
Collaborator

Controller names were reused as Lease holder identities. With concurrent reconciles, a second reconcile from the same controller matched the existing identity and entered the protected section. It could then stop the first reconcile's renewal or release its lock.

Build each locker ID from the acquiring object's kind, namespace, and name, followed by a UUID unique to the acquisition. Return a release function bound to that ID so callers cannot reconstruct ownership, and key renewal cancellation by the same ID.

Guard Lease deletion with UID and resource-version preconditions to stop a stale release from deleting a Lease changed by a newer acquisition. Migrate all locking controllers and replace the old reentrant-lock test with a concurrent-acquisition regression test.

Controller names were reused as Lease holder identities. With concurrent
reconciles, a second reconcile from the same controller matched the
existing identity and entered the protected section. It could then stop
the first reconcile's renewal or release its lock.

Build each locker ID from the acquiring object's kind, namespace, and
name, followed by a UUID unique to the acquisition. Return a release
function bound to that ID so callers cannot reconstruct ownership, and
key renewal cancellation by the same ID.

Guard Lease deletion with UID and resource-version preconditions to stop
a stale release from deleting a Lease changed by a newer acquisition.
Migrate all locking controllers and replace the old reentrant-lock test
with a concurrent-acquisition regression test.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Comment thread internal/resourcelock/resourcelock.go Resolved
@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (1 decrease, 5 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/controller/cisco/nx 64.97% (+1.42%) 👍
github.com/ironcore-dev/network-operator/internal/controller/core 60.09% (+0.14%) 👍
github.com/ironcore-dev/network-operator/internal/controller/evpn 81.20% (+0.30%) 👍
github.com/ironcore-dev/network-operator/internal/controller/overlay 66.36% (-4.55%) 👎
github.com/ironcore-dev/network-operator/internal/controller/pool 75.95% (+0.42%) 👍
github.com/ironcore-dev/network-operator/internal/resourcelock 69.61% (+1.24%) 👍
Coverage details

Compared to commit 711ee21 (run #38413362351)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/controller/cisco/nx/bordergateway_controller.go 53.33% (+1.03%) 240 (+1) 128 (+3) 112 (-2) 👍
github.com/ironcore-dev/network-operator/internal/controller/cisco/nx/system_controller.go 64.17% (+0.30%) 120 (+1) 77 (+1) 43 👍
github.com/ironcore-dev/network-operator/internal/controller/cisco/nx/vpcdomain_controller.go 78.67% (+2.48%) 211 (+1) 166 (+6) 45 (-5) 👍
github.com/ironcore-dev/network-operator/internal/controller/core/aaa_controller.go 0.00% (ø) 142 (+1) 0 142 (+1)
github.com/ironcore-dev/network-operator/internal/controller/core/acl_controller.go 56.94% (+0.30%) 144 (+1) 82 (+1) 62 👍
github.com/ironcore-dev/network-operator/internal/controller/core/banner_controller.go 56.98% (+0.25%) 172 (+1) 98 (+1) 74 👍
github.com/ironcore-dev/network-operator/internal/controller/core/bgp_controller.go 68.33% (+0.13%) 240 (+1) 164 (+1) 76 👍
github.com/ironcore-dev/network-operator/internal/controller/core/bgp_peer_controller.go 59.94% (+0.11%) 362 (+1) 217 (+1) 145 👍
github.com/ironcore-dev/network-operator/internal/controller/core/certificate_controller.go 58.23% (+0.27%) 158 (+1) 92 (+1) 66 👍
github.com/ironcore-dev/network-operator/internal/controller/core/communityset_controller.go 56.74% (+0.31%) 141 (+1) 80 (+1) 61 👍
github.com/ironcore-dev/network-operator/internal/controller/core/configbackup_controller.go 57.32% (+0.13%) 328 (+1) 188 (+1) 140 👍
github.com/ironcore-dev/network-operator/internal/controller/core/dhcprelay_controller.go 69.90% (+0.10%) 289 (+1) 202 (+1) 87 👍
github.com/ironcore-dev/network-operator/internal/controller/core/dns_controller.go 60.28% (+0.28%) 141 (+1) 85 (+1) 56 👍
github.com/ironcore-dev/network-operator/internal/controller/core/ethernetsegment_controller.go 63.51% (+0.17%) 211 (+1) 134 (+1) 77 👍
github.com/ironcore-dev/network-operator/internal/controller/core/evpninstance_controller.go 58.14% (-0.62%) 258 (+1) 150 (-1) 108 (+2) 👎
github.com/ironcore-dev/network-operator/internal/controller/core/interface_controller.go 71.38% (-0.63%) 594 (+1) 424 (-3) 170 (+4) 👎
github.com/ironcore-dev/network-operator/internal/controller/core/isis_controller.go 58.62% (+0.24%) 174 (+1) 102 (+1) 72 👍
github.com/ironcore-dev/network-operator/internal/controller/core/lldp_controller.go 68.78% (+1.51%) 221 (+1) 152 (+4) 69 (-3) 👍
github.com/ironcore-dev/network-operator/internal/controller/core/managementaccess_controller.go 56.74% (+0.31%) 141 (+1) 80 (+1) 61 👍
github.com/ironcore-dev/network-operator/internal/controller/core/ntp_controller.go 56.74% (+0.31%) 141 (+1) 80 (+1) 61 👍
github.com/ironcore-dev/network-operator/internal/controller/core/nve_controller.go 66.67% (-0.76%) 219 (+1) 146 (-1) 73 (+2) 👎
github.com/ironcore-dev/network-operator/internal/controller/core/ospf_controller.go 64.45% (+0.17%) 211 (+1) 136 (+1) 75 👍
github.com/ironcore-dev/network-operator/internal/controller/core/pim_controller.go 58.14% (+0.24%) 172 (+1) 100 (+1) 72 👍
github.com/ironcore-dev/network-operator/internal/controller/core/prefixset_controller.go 59.72% (+0.28%) 144 (+1) 86 (+1) 58 👍
github.com/ironcore-dev/network-operator/internal/controller/core/probe_controller.go 49.15% (+0.14%) 354 (+1) 174 (+1) 180 👍
github.com/ironcore-dev/network-operator/internal/controller/core/routingpolicy_controller.go 65.98% (+1.21%) 194 (+1) 128 (+3) 66 (-2) 👍
github.com/ironcore-dev/network-operator/internal/controller/core/snmp_controller.go 56.74% (+0.31%) 141 (+1) 80 (+1) 61 👍
github.com/ironcore-dev/network-operator/internal/controller/core/syslog_controller.go 56.94% (+0.30%) 144 (+1) 82 (+1) 62 👍
github.com/ironcore-dev/network-operator/internal/controller/core/user_controller.go 55.81% (+0.26%) 172 (+1) 96 (+1) 76 👍
github.com/ironcore-dev/network-operator/internal/controller/core/vlan_controller.go 60.78% (+0.26%) 153 (+1) 93 (+1) 60 👍
github.com/ironcore-dev/network-operator/internal/controller/core/vrf_controller.go 60.99% (+0.28%) 141 (+1) 86 (+1) 55 👍
github.com/ironcore-dev/network-operator/internal/resourcelock/resourcelock.go 69.61% (+1.24%) 102 (+4) 71 (+4) 31 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files:

  • github.com/ironcore-dev/network-operator/internal/resourcelock/resourcelock_test.go

@hardikdr hardikdr added the area/switch-automation Automation processes for network switch management and operations. label Oct 14, 2026
@hardikdr hardikdr added this to Roadmap Oct 14, 2026
@felix-kaestner
felix-kaestner merged commit 28a91e6 into main Oct 14, 2026
26 checks passed
@felix-kaestner
felix-kaestner deleted the fix/resourcelock branch October 14, 2026 12:02
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/switch-automation Automation processes for network switch management and operations. size/L

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants