Skip to content

Commit 4888f62

Browse files
authored
Bump leaselocker to v0.3.0 and switch to ll.UnlockWithRetry() (#417)
* Update leaselocker to v0.3.0 * Switch to leaselocker `UnlockWithRetry()` * Remove Lease deletion from e2e tests
1 parent 012893c commit 4888f62

File tree

17 files changed

+6
-54
lines changed

17 files changed

+6
-54
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/sirupsen/logrus v1.9.3
1818
github.com/spf13/viper v1.20.1
1919
github.com/stretchr/testify v1.10.0
20-
github.com/swisscom/leaselocker v0.2.0
20+
github.com/swisscom/leaselocker v0.3.0
2121
go.uber.org/mock v0.5.2
2222
go.uber.org/zap v1.27.0
2323
k8s.io/api v0.33.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
176176
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
177177
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
178178
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
179-
github.com/swisscom/leaselocker v0.2.0 h1:5bmfVD7TKzRMwQl4E9La3Lfwd80cKD4JOQjeXIqrLrM=
180-
github.com/swisscom/leaselocker v0.2.0/go.mod h1:34qA0RtskqaqOqdrGWihIg4sinJRzNDd8kbmwhhMPO0=
179+
github.com/swisscom/leaselocker v0.3.0 h1:kX8Bejnk51gj6EoSJye6CXblWnHlbLyreXVlawvPd4E=
180+
github.com/swisscom/leaselocker v0.3.0/go.mod h1:34qA0RtskqaqOqdrGWihIg4sinJRzNDd8kbmwhhMPO0=
181181
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
182182
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
183183
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

internal/controller/ipaddress_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (r *IpAddressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
202202

203203
// 3. unlock lease of parent prefix
204204
if ll != nil {
205-
ll.Unlock()
205+
ll.UnlockWithRetry(ctx)
206206
}
207207

208208
// 4. update status fields

internal/controller/iprange_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (r *IpRangeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
180180

181181
// 3. unlock lease of parent prefix
182182
if ll != nil {
183-
ll.Unlock()
183+
ll.UnlockWithRetry(ctx)
184184
}
185185

186186
// 4. update status fields

internal/controller/prefix_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (r *PrefixReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
217217

218218
/* 3. unlock lease of parent prefix */
219219
if ll != nil {
220-
ll.Unlock()
220+
ll.UnlockWithRetry(ctx)
221221
}
222222

223223
/* 4. update status fields */

tests/e2e/iprange/ipv4/iprangeclaim-ipv4-apply-update/chainsaw-test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,4 @@ spec:
116116
cleanup:
117117
- script:
118118
content: |-
119-
LEASES=$(kubectl -n netbox-operator-system get lease -oname | grep -v netbox) # to be enhanced in usage of leaselocker
120-
if [ -n "$LEASES" ]; then
121-
echo "$LEASES" | xargs -n1 kubectl -n netbox-operator-system delete
122-
fi
123119
kubectl delete events --field-selector involvedObject.name=iprangeclaim-ipv4-apply-update -n $NAMESPACE

tests/e2e/iprange/ipv4/iprangeclaim-ipv4-invalid-cidr/chainsaw-test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ spec:
1919
cleanup:
2020
- script:
2121
content: |-
22-
LEASES=$(kubectl -n netbox-operator-system get lease -oname | grep -v netbox) # to be enhanced in usage of leaselocker
23-
if [ -n "$LEASES" ]; then
24-
echo "$LEASES" | xargs -n1 kubectl -n netbox-operator-system delete
25-
fi
2622
kubectl delete events --field-selector involvedObject.name=iprangeclaim-ipv4-invalid-cidr -n $NAMESPACE

tests/e2e/iprange/ipv4/iprangeclaim-ipv4-invalid-customfieldnotexisting/chainsaw-test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,4 @@ spec:
6565
cleanup:
6666
- script:
6767
content: |-
68-
LEASES=$(kubectl -n netbox-operator-system get lease -oname | grep -v netbox) # to be enhanced in usage of leaselocker
69-
if [ -n "$LEASES" ]; then
70-
echo "$LEASES" | xargs -n1 kubectl -n netbox-operator-system delete
71-
fi
7268
kubectl delete events --field-selector involvedObject.name=iprangeclaim-ipv4-invalid-customfieldnotexisting -n $NAMESPACE

tests/e2e/iprange/ipv4/iprangeclaim-ipv4-invalid-customfieldwrongdatatype/chainsaw-test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,4 @@ spec:
6565
cleanup:
6666
- script:
6767
content: |-
68-
LEASES=$(kubectl -n netbox-operator-system get lease -oname | grep -v netbox) # to be enhanced in usage of leaselocker
69-
if [ -n "$LEASES" ]; then
70-
echo "$LEASES" | xargs -n1 kubectl -n netbox-operator-system delete
71-
fi
7268
kubectl delete events --field-selector involvedObject.name=iprangeclaim-ipv4-invalid-customfieldwrongdatatype -n $NAMESPACE

tests/e2e/iprange/ipv4/iprangeclaim-ipv4-invalid-parentprefix/chainsaw-test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,4 @@ spec:
3939
cleanup:
4040
- script:
4141
content: |-
42-
LEASES=$(kubectl -n netbox-operator-system get lease -oname | grep -v netbox) # to be enhanced in usage of leaselocker
43-
if [ -n "$LEASES" ]; then
44-
echo "$LEASES" | xargs -n1 kubectl -n netbox-operator-system delete
45-
fi
4642
kubectl delete events --field-selector involvedObject.name=iprangeclaim-ipv4-invalid-parentprefix -n $NAMESPACE

0 commit comments

Comments
 (0)