Skip to content

Commit

Permalink
fix: don't announce the VIP on acquire failure
Browse files Browse the repository at this point in the history
I noticed that while looking at siderolabs#8493, but I don't know if this problem
actually happened in real life.

If acquiring a VIP fails (which can only fail for Equinix/HCloud, not L2
ARP announce), we should not set the leader flag, as it would make the
controller announce the IP, while it shouldn't do that.

If this call fails, there's no matching call to de-announce on failure.

The bug would show up as two nodes having same VIP assigned on the host.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Apr 3, 2024
1 parent 1b17008 commit a06653b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/app/machined/pkg/controllers/network/operator/vip.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ func (vip *VIP) markAsLeader(ctx context.Context, notifyCh chan<- struct{}, lead

if leader {
handlerErr = vip.handler.Acquire(ctx)

if handlerErr != nil {
// if failed to acquire, we are not a leader, we will resign from the election
// so don't mark as leader, so that Talos doesn't announce IPs on the host
leader = false
}
} else {
handlerErr = vip.handler.Release(ctx)
}
Expand Down

0 comments on commit a06653b

Please sign in to comment.