(ctx context.Context)
| 1076 | } |
| 1077 | |
| 1078 | func (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 | |
| 1104 | func (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) |
no test coverage detected