()
| 163 | } |
| 164 | |
| 165 | func (t *Cortex) initRuntimeConfig() (services.Service, error) { |
| 166 | if t.Cfg.RuntimeConfig.LoadPath == "" { |
| 167 | // no need to initialize module if load path is empty |
| 168 | return nil, nil |
| 169 | } |
| 170 | runtimeConfigLoader := runtimeConfigLoader{cfg: t.Cfg} |
| 171 | t.Cfg.RuntimeConfig.Loader = runtimeConfigLoader.load |
| 172 | |
| 173 | // make sure to set default limits before we start loading configuration into memory |
| 174 | validation.SetDefaultLimitsForYAMLUnmarshalling(t.Cfg.LimitsConfig) |
| 175 | |
| 176 | registerer := prometheus.WrapRegistererWithPrefix("cortex_", prometheus.DefaultRegisterer) |
| 177 | logger := util_log.Logger |
| 178 | bucketClientFactory := func(ctx context.Context) (objstore.Bucket, error) { |
| 179 | // When directory is an empty string but the runtime-config.file is an absolute path, |
| 180 | // the filesystem.NewBucketClient will treat it as a relative path based on the current working directory |
| 181 | // that the process is running in. |
| 182 | if t.Cfg.RuntimeConfig.StorageConfig.Backend == bucket.Filesystem { |
| 183 | if t.Cfg.RuntimeConfig.StorageConfig.Filesystem.Directory == "" { |
| 184 | // Check if runtime-config.file is an absolute path |
| 185 | if t.Cfg.RuntimeConfig.LoadPath[0] == '/' { |
| 186 | // If it is, set the directory to the root directory so that the filesystem bucket |
| 187 | // will treat it as an absolute path. This is to maintain backwards compatibility |
| 188 | // with the previous behavior of the runtime-config.file of allowing relative and absolute paths. |
| 189 | t.Cfg.RuntimeConfig.StorageConfig.Filesystem.Directory = "/" |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | return bucket.NewClient(ctx, t.Cfg.RuntimeConfig.StorageConfig, nil, "runtime-config", logger, registerer) |
| 194 | } |
| 195 | serv, err := runtimeconfig.New(t.Cfg.RuntimeConfig, registerer, logger, bucketClientFactory) |
| 196 | if err == nil { |
| 197 | // TenantLimits just delegates to RuntimeConfig and doesn't have any state or need to do |
| 198 | // anything in the start/stopping phase. Thus we can create it as part of runtime config |
| 199 | // setup without any service instance of its own. |
| 200 | t.TenantLimits = newTenantLimits(serv) |
| 201 | } |
| 202 | |
| 203 | t.RuntimeConfig = serv |
| 204 | t.API.RegisterRuntimeConfig(runtimeConfigHandler(t.RuntimeConfig, t.Cfg.LimitsConfig)) |
| 205 | return serv, err |
| 206 | } |
| 207 | |
| 208 | func (t *Cortex) initOverridesConfig() (services.Service, error) { |
| 209 | t.OverridesConfig = validation.NewOverrides(t.Cfg.LimitsConfig, t.TenantLimits) |
nothing calls this directly
no test coverage detected