MCPcopy
hub / github.com/grafana/tempo / fetchSeed

Method fetchSeed

pkg/usagestats/reporter.go:188–214  ·  view source on GitHub ↗

fetchSeed fetches the cluster seed from the object store and try until it succeeds. continueFn allow you to decide if we should continue retrying. Nil means always retry

(ctx context.Context, continueFn func(err error) bool)

Source from the content-addressed store, hash-verified

186// fetchSeed fetches the cluster seed from the object store and try until it succeeds.
187// continueFn allow you to decide if we should continue retrying. Nil means always retry
188func (rep *Reporter) fetchSeed(ctx context.Context, continueFn func(err error) bool) (*ClusterSeed, error) {
189 var (
190 backoff = backoff.New(ctx, rep.conf.Backoff)
191 readingErr = 0
192 )
193 for backoff.Ongoing() {
194 seed, err := rep.readSeedFile(ctx)
195 if err != nil {
196 if !errors.Is(err, backend.ErrDoesNotExist) {
197 readingErr++
198 }
199 level.Debug(rep.logger).Log("msg", "failed to read cluster seed file", "err", err)
200 if readingErr > attemptNumber {
201 if errors.Is(err, backend.ErrBadSeedFile) {
202 level.Debug(rep.logger).Log("msg", "seed file corrupted")
203 }
204 }
205 if continueFn == nil || continueFn(err) {
206 backoff.Wait()
207 continue
208 }
209 return nil, err
210 }
211 return seed, nil
212 }
213 return nil, backoff.Err()
214}
215
216// readSeedFile reads the cluster seed file from the object store.
217func (rep *Reporter) readSeedFile(ctx context.Context) (*ClusterSeed, error) {

Callers 2

initLeaderMethod · 0.95
initMethod · 0.95

Calls 3

readSeedFileMethod · 0.95
LogMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected