mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
VAULT-38228 CE side of sighup for observations (#31384)
* VAULT-38228 CE side of sighup for observations * reload CE
This commit is contained in:
parent
c80c4b4180
commit
b35bd44e9b
@ -2304,6 +2304,15 @@ func (c *ServerCommand) Reload(lock *sync.RWMutex, reloadFuncs *map[string][]rel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case strings.HasPrefix(k, "observations|"):
|
||||||
|
for _, relFunc := range relFuncs {
|
||||||
|
if relFunc != nil {
|
||||||
|
if err := relFunc(); err != nil {
|
||||||
|
reloadErrors = multierror.Append(reloadErrors, fmt.Errorf("error encountered reloading observation system with ledger at path %q: %w", strings.TrimPrefix(k, "observations|"), err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1394,12 +1394,10 @@ func NewCore(conf *CoreConfig) (*Core, error) {
|
|||||||
LocalNodeId: nodeID,
|
LocalNodeId: nodeID,
|
||||||
Logger: observationsLogger,
|
Logger: observationsLogger,
|
||||||
}
|
}
|
||||||
observations, err := observations.NewObservationSystem(config)
|
err = c.AddObservationSystemToCore(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c.observations = observations
|
|
||||||
c.observations.Start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1407,6 +1405,30 @@ func NewCore(conf *CoreConfig) (*Core, error) {
|
|||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Core) AddObservationSystemToCore(config *observations.NewObservationSystemConfig) error {
|
||||||
|
observations, err := observations.NewObservationSystem(config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.observations = observations
|
||||||
|
|
||||||
|
c.reloadFuncsLock.Lock()
|
||||||
|
|
||||||
|
// While it's only possible to configure one observation system now, making the key
|
||||||
|
// include the path future-proofs us going forward.
|
||||||
|
key := "observations|" + config.LedgerPath
|
||||||
|
c.reloadFuncs[key] = append(c.reloadFuncs[key], func() error {
|
||||||
|
config.Logger.Info("reloading observation system", "path", config.LedgerPath)
|
||||||
|
return observations.Reload()
|
||||||
|
})
|
||||||
|
|
||||||
|
c.reloadFuncsLock.Unlock()
|
||||||
|
|
||||||
|
c.observations.Start()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// configureListeners configures the Core with the listeners from the CoreConfig.
|
// configureListeners configures the Core with the listeners from the CoreConfig.
|
||||||
func (c *Core) configureListeners(conf *CoreConfig) error {
|
func (c *Core) configureListeners(conf *CoreConfig) error {
|
||||||
c.clusterListener.Store((*cluster.Listener)(nil))
|
c.clusterListener.Store((*cluster.Listener)(nil))
|
||||||
|
@ -34,3 +34,7 @@ func (observations *ObservationSystem) RecordObservationToLedger(_ context.Conte
|
|||||||
func NewObservationSystem(_ *NewObservationSystemConfig) (*ObservationSystem, error) {
|
func NewObservationSystem(_ *NewObservationSystemConfig) (*ObservationSystem, error) {
|
||||||
return &ObservationSystem{}, nil
|
return &ObservationSystem{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (observations *ObservationSystem) Reload() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user