Skip to content

Commit

Permalink
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) (#9269)
  • Loading branch information
ncabatoff authored Jun 22, 2020
1 parent b8bd013 commit e7454fd
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
Expand Up @@ -1827,7 +1827,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.
Expand Down Expand Up @@ -2358,15 +2358,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) {
Expand Down

0 comments on commit e7454fd

Please sign in to comment.