in build-index/tagserver/server.go [510:554]
func (s *Server) putTag(ctx context.Context, tag string, d core.Digest, deps core.DigestList) error {
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "dependency_count", len(deps)).Debug("Validating tag dependencies")
for _, dep := range deps {
if _, err := s.localOriginClient.Stat(tag, dep); err == blobclient.ErrBlobNotFound {
return fmt.Errorf("cannot upload tag, missing dependency %s", dep)
} else if err != nil {
return fmt.Errorf("check blob: %w", err)
}
}
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String()).Debug("All dependencies validated successfully")
if err := s.store.Put(ctx, tag, d, 0); err != nil {
return fmt.Errorf("storage: %w", err)
}
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String()).Info("Tag stored locally")
neighbors := s.neighbors.Resolve()
neighborCount := len(neighbors)
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "neighbor_count", neighborCount).Debug("Starting neighbor replication")
var delay time.Duration
var successes int
for addr := range neighbors {
delay += s.config.DuplicatePutStagger
client := s.provider.Provide(addr)
if err := client.DuplicatePut(tag, d, delay); err != nil {
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "neighbor", addr, "delay", delay, "error", err).Error("Failed to duplicate put to neighbor")
} else {
successes++
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "neighbor", addr, "delay", delay).Debug("Successfully duplicated put to neighbor")
}
}
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "total_neighbors", neighborCount, "successful_neighbors", successes, "failed_neighbors", neighborCount-successes).Info("Completed neighbor replication")
if len(neighbors) != 0 && successes == 0 {
s.stats.Counter("duplicate_put_failures").Inc(1)
log.WithTraceContext(ctx).With("tag", tag, "digest", d.String(), "neighbor_count", neighborCount).Error("All neighbor replications failed")
}
return nil
}