MCPcopy Create free account
hub / github.com/cortexproject/cortex / loadConfig

Method loadConfig

pkg/util/runtimeconfig/manager.go:168–191  ·  view source on GitHub ↗

loadConfig loads configuration using the loader function, and if successful, stores it as current configuration and notifies listeners.

(ctx context.Context)

Source from the content-addressed store, hash-verified

166// loadConfig loads configuration using the loader function, and if successful,
167// stores it as current configuration and notifies listeners.
168func (om *Manager) loadConfig(ctx context.Context) error {
169 buf, err := om.loadConfigFromBucket(ctx)
170
171 if err != nil {
172 om.configLoadSuccess.Set(0)
173 return errors.Wrap(err, "read file")
174 }
175 hash := sha256.Sum256(buf)
176
177 cfg, err := om.cfg.Loader(bytes.NewReader(buf))
178 if err != nil {
179 om.configLoadSuccess.Set(0)
180 return errors.Wrap(err, "load file")
181 }
182 om.configLoadSuccess.Set(1)
183
184 om.setConfig(cfg)
185 om.callListeners(cfg)
186
187 // expose hash of runtime config
188 om.configHash.Reset()
189 om.configHash.WithLabelValues(fmt.Sprintf("%x", hash[:])).Set(1)
190 return nil
191}
192
193func (om *Manager) loadConfigFromBucket(ctx context.Context) ([]byte, error) {
194 readCloser, err := om.bucketClient.Get(ctx, om.cfg.LoadPath)

Callers 5

startingMethod · 0.95
loopMethod · 0.95

Calls 6

loadConfigFromBucketMethod · 0.95
setConfigMethod · 0.95
callListenersMethod · 0.95
SetMethod · 0.65
WrapMethod · 0.65
ResetMethod · 0.45