Skip to content

Commit

Permalink
don't remove itself if node is a raft leader
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-kripakov-m10 committed Dec 20, 2023
1 parent a4b60fc commit 3ee19e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ release:
-e DOCKER_USERNAME \
-e DOCKER_PASSWORD \
-e DOCKER_REGISTRY \
-e GORELEASER_CURRENT_TAG=v3.2.7-M3 \
-e GORELEASER_CURRENT_TAG=v3.2.7-M4 \
-v /var/run/docker.sock:/var/run/docker.sock \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist --skip-validate --timeout=1h
Expand Down
10 changes: 10 additions & 0 deletions dkron/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dkron
import (
"fmt"
"net"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -315,6 +316,15 @@ func (a *Agent) addRaftPeer(m serf.Member, parts *ServerParts) error {
// removeRaftPeer is used to remove a Raft peer when a dkron server leaves
// or is reaped
func (a *Agent) removeRaftPeer(m serf.Member, parts *ServerParts) error {

// Do not remove ourself. This can only happen if the current leader
// is leaving. Instead, we should allow a follower to take-over and
// deregister us later.
if strings.EqualFold(m.Name, a.config.NodeName) {
a.logger.Warn("removing self should be done by follower", "name", a.config.NodeName)
return nil
}

// See if it's already in the configuration. It's harmless to re-remove it
// but we want to avoid doing that if possible to prevent useless Raft
// log entries.
Expand Down

0 comments on commit 3ee19e9

Please sign in to comment.