Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for incompatible seal types between raft leader and new follower after having downgraded to one seal #26523

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/26523.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core (enterprise): fix bug where raft followers disagree with the seal type after returning to one seal from two.
```
4 changes: 2 additions & 2 deletions vault/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,8 @@ func (c *Core) getRaftChallenge(leaderInfo *raft.LeaderJoinInfo) (*raftInformati
return nil, err
}

if sealConfig.Type != c.seal.BarrierSealConfigType().String() {
return nil, fmt.Errorf("mismatching seal types between raft leader (%s) and follower (%s)", sealConfig.Type, c.seal.BarrierSealConfigType())
if !CompatibleSealTypes(sealConfig.Type, c.seal.BarrierSealConfigType().String()) {
return nil, fmt.Errorf("incompatible seal types between raft leader (%s) and follower (%s)", sealConfig.Type, c.seal.BarrierSealConfigType())
}

challengeB64, ok := secret.Data["challenge"]
Expand Down
6 changes: 5 additions & 1 deletion vault/seal_autoseal.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (d *autoSeal) BarrierConfig(ctx context.Context) (*SealConfig, error) {

barrierTypeUpgradeCheck(d.BarrierSealConfigType(), conf)

if conf.Type != d.BarrierSealConfigType().String() && conf.Type != SealConfigTypeMultiseal.String() && d.BarrierSealConfigType() != SealConfigTypeMultiseal {
if !CompatibleSealTypes(conf.Type, d.BarrierSealConfigType().String()) {
d.logger.Error("barrier seal type does not match loaded type", "seal_type", conf.Type, "loaded_type", d.BarrierSealConfigType())
return nil, fmt.Errorf("barrier seal type of %q does not match loaded type of %q", conf.Type, d.BarrierSealConfigType())
}
Expand All @@ -203,6 +203,10 @@ func (d *autoSeal) BarrierConfig(ctx context.Context) (*SealConfig, error) {
return conf.Clone(), nil
}

func CompatibleSealTypes(a, b string) bool {
return a == b || a == SealConfigTypeMultiseal.String() || b == SealConfigTypeMultiseal.String()
}

func (d *autoSeal) ClearBarrierConfig(ctx context.Context) error {
return d.SetBarrierConfig(ctx, nil)
}
Expand Down
Loading