MCPcopy
hub / github.com/grafana/dskit / processShutdown

Method processShutdown

ring/lifecycler.go:1078–1102  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1076}
1077
1078func (i *Lifecycler) processShutdown(ctx context.Context) {
1079 flushRequired := i.FlushOnShutdown()
1080 transferStart := time.Now()
1081 if err := i.flushTransferer.TransferOut(ctx); err != nil {
1082 if err == ErrTransferDisabled {
1083 level.Info(i.logger).Log("msg", "transfers are disabled")
1084 } else {
1085 level.Error(i.logger).Log("msg", "failed to transfer chunks to another instance", "ring", i.RingName, "err", err)
1086 i.lifecyclerMetrics.shutdownDuration.WithLabelValues("transfer", "fail").Observe(time.Since(transferStart).Seconds())
1087 }
1088 } else {
1089 flushRequired = false
1090 i.lifecyclerMetrics.shutdownDuration.WithLabelValues("transfer", "success").Observe(time.Since(transferStart).Seconds())
1091 }
1092
1093 if flushRequired {
1094 flushStart := time.Now()
1095 i.flushTransferer.Flush()
1096 i.lifecyclerMetrics.shutdownDuration.WithLabelValues("flush", "success").Observe(time.Since(flushStart).Seconds())
1097 }
1098
1099 // Sleep so the shutdownDuration metric can be collected.
1100 level.Info(i.logger).Log("msg", "lifecycler entering final sleep before shutdown", "final_sleep", i.cfg.FinalSleep)
1101 time.Sleep(i.cfg.FinalSleep)
1102}
1103
1104func (i *Lifecycler) casRing(ctx context.Context, f func(in interface{}) (out interface{}, retry bool, err error)) error {
1105 return i.KVStore.CAS(ctx, i.RingKey, f)

Callers 1

stoppingMethod · 0.95

Calls 6

FlushOnShutdownMethod · 0.95
TransferOutMethod · 0.65
FlushMethod · 0.65
SleepMethod · 0.65
LogMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected