BeryJu/gravity

Lease update may result in the client in one scope but assigned an address from another scope

GrantRoot1970 opened this issue · 0 comments

When a client with an existing lease changes networks resulting in a different scope that should apply, the lease will remain in the existing scope, but be assigned an address from the new scope.

This appears to be because the code in leases.go does not update the key for the scope (see the following patch). This bug may relate to existing issues, but I did not review any others.

PATCH

--- leases.go.bug       2024-01-27 17:54:29.312552703 -0500
+++ leases.go   2024-01-27 17:13:13.000000000 -0500
@@ -53,6 +53,7 @@
        if expectedScope != nil && lease.scope != expectedScope {
                // We have a specific scope to handle this request but it doesn't match the lease
                lease.scope = expectedScope
+               lease.ScopeKey = expectedScope.Name
                lease.setLeaseIP(req)
                lease.log.Info("Re-assigning address for lease due to changed request scope", zap.String("newIP", lease.Address))
                go func() {