Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
cluster: fix a big where cluster state get overwritten on restart.
Browse files Browse the repository at this point in the history
The cluster package was not acting correctly when discovering
existing cluster state. This meant that cluster info was being
overwritten which is not the itended behaviour. This now fixes
the issue.

closes #76
  • Loading branch information
jrasell committed Oct 25, 2019
1 parent 543384d commit b1a894d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions pkg/server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ func (m *Member) setupCluster() error {
// If existing state is found, check whether the operator passed cluster name matches the one
// found. If the passed one does not match the state, we will fail with an error.
if c.Name != "" && c.ID != uuid.Nil {
if err := m.verifyClusterName(c.Name); err != nil {
return err
}
m.logger.Debug().Msg("found existing Sherpa cluster state, verifying data")
return m.verifyClusterName(c.Name)
}

if err := m.generateClusterName(); err != nil {
Expand All @@ -49,7 +48,7 @@ func (m *Member) verifyClusterName(name string) error {
}
}

m.logger.Info().Msg("successfully found cluster state of existing cluster to join")
m.logger.Info().Msg("successfully verified state of existing cluster to join")
m.clusterName = name
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/cluster/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Member struct { // nolint:maligned
stateLock sync.RWMutex
logger zerolog.Logger

// clusterName
// clusterName represents the name of the cluster this Sherpa instance is a part of.
clusterName string

// standby is used to determine whether the Sherpa server in question is currently in standby
Expand Down

0 comments on commit b1a894d

Please sign in to comment.