VAULT-38228 CE side of sighup for observations (#31384)

* VAULT-38228 CE side of sighup for observations

* reload CE
This commit is contained in:
Violet Hynes 2025-07-30 16:13:35 -04:00 committed by GitHub
parent c80c4b4180
commit b35bd44e9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 3 deletions

View File

@ -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))
}
}
}
} }
} }

View File

@ -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))

View File

@ -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
}