mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-29 14:41:09 +01:00
core: add postSealMigration method (#7579)
* core: add postSealMigration method The postSealMigration method is called at the end of the postUnseal method if a seal migration has occurred. This starts a seal rewrap process in the enterprise version of. It is a no-op in the OSS version.
This commit is contained in:
parent
d9a869b45a
commit
50bd355f11
@ -203,6 +203,7 @@ type Core struct {
|
|||||||
// migrationSeal is the seal to use during a migration operation. It is the
|
// migrationSeal is the seal to use during a migration operation. It is the
|
||||||
// seal we're migrating *from*.
|
// seal we're migrating *from*.
|
||||||
migrationSeal Seal
|
migrationSeal Seal
|
||||||
|
sealMigrated *uint32
|
||||||
|
|
||||||
// unwrapSeal is the seal to use on Enterprise to unwrap values wrapped
|
// unwrapSeal is the seal to use on Enterprise to unwrap values wrapped
|
||||||
// with the previous seal.
|
// with the previous seal.
|
||||||
@ -645,6 +646,7 @@ func NewCore(conf *CoreConfig) (*Core, error) {
|
|||||||
seal: conf.Seal,
|
seal: conf.Seal,
|
||||||
router: NewRouter(),
|
router: NewRouter(),
|
||||||
sealed: new(uint32),
|
sealed: new(uint32),
|
||||||
|
sealMigrated: new(uint32),
|
||||||
standby: true,
|
standby: true,
|
||||||
baseLogger: conf.Logger,
|
baseLogger: conf.Logger,
|
||||||
logger: conf.Logger.Named("core"),
|
logger: conf.Logger.Named("core"),
|
||||||
@ -1175,6 +1177,7 @@ func (c *Core) unsealPart(ctx context.Context, seal Seal, key []byte, useRecover
|
|||||||
// At this point we've swapped things around and need to ensure we
|
// At this point we've swapped things around and need to ensure we
|
||||||
// don't migrate again
|
// don't migrate again
|
||||||
c.migrationSeal = nil
|
c.migrationSeal = nil
|
||||||
|
atomic.StoreUint32(c.sealMigrated, 1)
|
||||||
|
|
||||||
// Ensure we populate the new values
|
// Ensure we populate the new values
|
||||||
bc, err := c.seal.BarrierConfig(ctx)
|
bc, err := c.seal.BarrierConfig(ctx)
|
||||||
@ -1738,6 +1741,11 @@ func (c *Core) postUnseal(ctx context.Context, ctxCancelFunc context.CancelFunc,
|
|||||||
v()
|
v()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if atomic.LoadUint32(c.sealMigrated) == 1 {
|
||||||
|
defer func() { atomic.StoreUint32(c.sealMigrated, 0) }()
|
||||||
|
c.postSealMigration(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
c.logger.Info("post-unseal setup complete")
|
c.logger.Info("post-unseal setup complete")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,3 +124,5 @@ func (c *Core) perfStandbyClusterHandler() (*replication.Cluster, *cache.Cache,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) initSealsForMigration() {}
|
func (c *Core) initSealsForMigration() {}
|
||||||
|
|
||||||
|
func (c *Core) postSealMigration(ctx context.Context) error { return nil }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user