(ctx context.Context)
| 944 | } |
| 945 | |
| 946 | func (i *Ingester) starting(ctx context.Context) error { |
| 947 | // Important: we want to keep lifecycler running until we ask it to stop, so we need to give it independent context |
| 948 | if err := i.lifecycler.StartAsync(context.Background()); err != nil { |
| 949 | return errors.Wrap(err, "failed to start lifecycler") |
| 950 | } |
| 951 | if err := i.lifecycler.AwaitRunning(ctx); err != nil { |
| 952 | return errors.Wrap(err, "failed to start lifecycler") |
| 953 | } |
| 954 | |
| 955 | if err := i.openExistingTSDB(ctx); err != nil { |
| 956 | // Try to rollback and close opened TSDBs before halting the ingester. |
| 957 | i.closeAllTSDB() |
| 958 | |
| 959 | return errors.Wrap(err, "opening existing TSDBs") |
| 960 | } |
| 961 | |
| 962 | i.lifecycler.Join() |
| 963 | |
| 964 | // let's start the rest of subservices via manager |
| 965 | servs := []services.Service(nil) |
| 966 | |
| 967 | // Start active queried series service if enabled |
| 968 | if i.activeQueriedSeriesService != nil { |
| 969 | servs = append(servs, i.activeQueriedSeriesService) |
| 970 | } |
| 971 | |
| 972 | compactionService := services.NewBasicService(nil, i.compactionLoop, nil) |
| 973 | servs = append(servs, compactionService) |
| 974 | |
| 975 | if i.cfg.BlocksStorageConfig.TSDB.IsBlocksShippingEnabled() { |
| 976 | shippingService := services.NewBasicService(nil, i.shipBlocksLoop, nil) |
| 977 | servs = append(servs, shippingService) |
| 978 | } |
| 979 | |
| 980 | if i.cfg.BlocksStorageConfig.TSDB.CloseIdleTSDBTimeout > 0 { |
| 981 | interval := i.cfg.BlocksStorageConfig.TSDB.CloseIdleTSDBInterval |
| 982 | if interval == 0 { |
| 983 | interval = cortex_tsdb.DefaultCloseIdleTSDBInterval |
| 984 | } |
| 985 | closeIdleService := services.NewTimerService(interval, nil, i.closeAndDeleteIdleUserTSDBs, nil) |
| 986 | servs = append(servs, closeIdleService) |
| 987 | } |
| 988 | |
| 989 | if i.expandedPostingsCacheFactory != nil { |
| 990 | interval := i.cfg.BlocksStorageConfig.TSDB.ExpandedCachingExpireInterval |
| 991 | if interval == 0 { |
| 992 | interval = cortex_tsdb.ExpandedCachingExpireInterval |
| 993 | } |
| 994 | servs = append(servs, services.NewTimerService(interval, nil, i.expirePostingsCache, nil)) |
| 995 | } |
| 996 | |
| 997 | var err error |
| 998 | i.TSDBState.subservices, err = services.NewManager(servs...) |
| 999 | if err == nil { |
| 1000 | err = services.StartManagerAndAwaitHealthy(ctx, i.TSDBState.subservices) |
| 1001 | } |
| 1002 | return errors.Wrap(err, "failed to start ingester components") |
| 1003 | } |
nothing calls this directly
no test coverage detected