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

Method stopping

ring/partition_instance_lifecycler.go:207–224  ·  view source on GitHub ↗
(_ error)

Source from the content-addressed store, hash-verified

205}
206
207func (l *PartitionInstanceLifecycler) stopping(_ error) error {
208 level.Info(l.logger).Log("msg", "partition ring lifecycler is shutting down", "ring", l.ringName)
209
210 // Remove the instance from partition owners, if configured to do so.
211 if l.RemoveOwnerOnShutdown() {
212 err := l.updateRing(context.Background(), func(ring *PartitionRingDesc) (bool, error) {
213 return ring.RemoveOwner(l.partitionOwnerID()), nil
214 })
215
216 if err != nil {
217 level.Error(l.logger).Log("msg", "failed to remove instance from partition owners on shutdown", "instance", l.cfg.InstanceID, "partition_owner_id", l.partitionOwnerID(), "partition", l.cfg.PartitionID, "err", err)
218 } else {
219 level.Info(l.logger).Log("msg", "instance removed from partition owners", "instance", l.cfg.InstanceID, "partition_owner_id", l.partitionOwnerID(), "partition", l.cfg.PartitionID)
220 }
221 }
222
223 return nil
224}
225
226// runOnLifecyclerLoop runs fn within the lifecycler loop.
227func (l *PartitionInstanceLifecycler) runOnLifecyclerLoop(fn func() error) error {

Callers

nothing calls this directly

Calls 6

RemoveOwnerOnShutdownMethod · 0.95
updateRingMethod · 0.95
partitionOwnerIDMethod · 0.95
RemoveOwnerMethod · 0.80
LogMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected