Skip to content

Commit

Permalink
fix: ignore 'not a leader' error on forfeit leadership
Browse files Browse the repository at this point in the history
When forfeiting etcd leadership, it might be that the node still reports
leadership status while not being a leader once the actual API call is
used. We should ignore such an error as the node is not a leader.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Jul 5, 2021
1 parent 22a4193 commit aaa36f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/pkg/etcd/etcd.go
Expand Up @@ -6,6 +6,7 @@ package etcd

import (
"context"
"errors"
"fmt"
"log"
"net/url"
Expand Down Expand Up @@ -259,6 +260,11 @@ func (c *Client) ForfeitLeadership(ctx context.Context) (string, error) {

_, err = c.MoveLeader(ctx, m.GetID())
if err != nil {
if errors.Is(err, rpctypes.ErrNotLeader) {
// this member is not a leader anymore, so nothing to be done for the forfeit leadership
return "", nil
}

return "", err
}

Expand Down

0 comments on commit aaa36f3

Please sign in to comment.