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 #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>
(cherry picked from commit 5c0f74b)
  • Loading branch information
smira committed Jul 22, 2024
1 parent 67c76e8 commit dd241d7
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 dd241d7

Please sign in to comment.