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

Method starting

pkg/ingester/ingester.go:946–1003  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

944}
945
946func (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}

Callers

nothing calls this directly

Implementers 1

Ingesterpkg/ingester/ingester.go

Calls 11

openExistingTSDBMethod · 0.95
closeAllTSDBMethod · 0.95
NewBasicServiceFunction · 0.92
NewTimerServiceFunction · 0.92
NewManagerFunction · 0.92
JoinMethod · 0.80
StartAsyncMethod · 0.65
WrapMethod · 0.65
AwaitRunningMethod · 0.65

Tested by

no test coverage detected