Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix feature flag persistence: we shouldn't have excluded dr primaries…
Browse files Browse the repository at this point in the history
…, they too must write feature flags. DR secondaries might not need depend on feature flags being there, but a DR primary could also be (or become) a perf primary. (#9148)
ncabatoff authored and andaley committed Jul 17, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f40b635 commit d7dfa94
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions vault/core.go
Original file line number Diff line number Diff line change
@@ -1839,7 +1839,7 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c
if err := enterprisePostUnseal(c); err != nil {
return err
}
if !c.ReplicationState().HasState(consts.ReplicationPerformanceSecondary | consts.ReplicationDRPrimary | consts.ReplicationDRSecondary) {
if !c.ReplicationState().HasState(consts.ReplicationPerformanceSecondary | consts.ReplicationDRSecondary) {
// Only perf primarys should write feature flags, but we do it by
// excluding other states so that we don't have to change it when
// a non-replicated cluster becomes a primary.
@@ -2381,15 +2381,18 @@ type FeatureFlags struct {
}

func (c *Core) persistFeatureFlags(ctx context.Context) error {
c.logger.Debug("persisting feature flags")
json, err := jsonutil.EncodeJSON(&FeatureFlags{NamespacesCubbyholesLocal: !c.PR1103disabled})
if err != nil {
return err
if !c.PR1103disabled {
c.logger.Debug("persisting feature flags")
json, err := jsonutil.EncodeJSON(&FeatureFlags{NamespacesCubbyholesLocal: !c.PR1103disabled})
if err != nil {
return err
}
return c.barrier.Put(ctx, &logical.StorageEntry{
Key: consts.CoreFeatureFlagPath,
Value: json,
})
}
return c.barrier.Put(ctx, &logical.StorageEntry{
Key: consts.CoreFeatureFlagPath,
Value: json,
})
return nil
}

func (c *Core) readFeatureFlags(ctx context.Context) (*FeatureFlags, error) {

0 comments on commit d7dfa94

Please sign in to comment.