Skip to content

Commit

Permalink
WIP disable addr change; doc comments
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Jun 12, 2024
1 parent 63428a6 commit dedbb73
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cluster/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
dqliteClient "github.com/canonical/go-dqlite/client"
)

// Member is the information that can be derived locally about a cluster member
// without access to the dqlite database.
type Member struct {
// dqlite.NodeInfo fields
DqliteID uint64 `json:"id" yaml:"id"`
Expand All @@ -16,7 +18,8 @@ type Member struct {
Name string `json:"name" yaml:"name"`
}

func (m Member) ToNodeInfo() (*dqlite.NodeInfo, error) {
// NodeInfo is used for interop with go-dqlite

Check failure on line 21 in cluster/recover.go

View workflow job for this annotation

GitHub Actions / Code

Comment should end in a period (godot)
func (m Member) NodeInfo() (*dqlite.NodeInfo, error) {
var role dqliteClient.NodeRole
switch m.Role {
case "voter":
Expand Down
3 changes: 1 addition & 2 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ func (d *Daemon) Run(ctx context.Context, listenPort string, stateDir string, so
return fmt.Errorf("Failed to initialize directory structure: %w", err)
}

//TODO Maybe move to Daemon - update address changes? Only one DB update is
// needed
//TODO update address changes? Only one DB update is needed
err = recover.MaybeUnpackRecoveryTarball(d.os)
if err != nil {
return fmt.Errorf("Database recovery failed: %w", err)
Expand Down
14 changes: 12 additions & 2 deletions microcluster/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ func (m *MicroCluster) JoinCluster(ctx context.Context, name string, address str
return c.ControlDaemon(ctx, internalTypes.Control{JoinToken: token, Address: addr, Name: name, InitConfig: initConfig})
}

// GetLocalClusterMembers retrieves the current local cluster configuration
// (derived from the trust store & dqlite metadata); it does not query the
// database.
// This is primarily intended for modifying the cluster configuration via
// MicroCluster.RecoverFromQuorumLoss.
func (m *MicroCluster) GetLocalClusterMembers() ([]cluster.Member, error) {
return recover.GetLocalClusterMembers(m.FileSystem)
}
Expand Down Expand Up @@ -244,7 +249,12 @@ func (m *MicroCluster) RecoverFromQuorumLoss(members []cluster.Member) error {
countNewMembers := 0
for _, newMember := range members {
for _, oldMember := range oldMembers {
if newMember.DqliteID == oldMember.DqliteID && newMember.Name == oldMember.Name {
//FIXME: Allow changing member addresses as part of cluster recovery
membersMatch := newMember.DqliteID == oldMember.DqliteID &&
newMember.Name == oldMember.Name &&
newMember.Address == oldMember.Address

if membersMatch {
countNewMembers += 1
break
}
Expand All @@ -267,7 +277,7 @@ func (m *MicroCluster) RecoverFromQuorumLoss(members []cluster.Member) error {
// Set up our new cluster configuration
nodeInfo := make([]dqlite.NodeInfo, 0, len(members))
for _, member := range members {
info, err := member.ToNodeInfo()
info, err := member.NodeInfo()
if err != nil {
return err
}
Expand Down

0 comments on commit dedbb73

Please sign in to comment.