cli: dedup mirror-active filter and cell-fallback logging · Entire
cli: dedup mirror-active filter and cell-fallback logging
95c716d · Soph · 1w ago · 2 files · +20 added/-15 removed
Cleanups from a simplify pass over the activity/recap routing:
- Extract isActiveMirror(coreapi.Mirror) — the archived + failed/suspended placement filter that firstActiveRepoID and distinctActiveClusterHosts each spelled out — so "can this placement serve the repo" has one home; a new non-serving status now only needs updating there.
- Extract logCellClientFallback for the two cell→data-API call sites, replacing the duplicated inverse-condition debug log. It also drops the noise for the expected not-logged-in case (not just no-cell-yet), and removes the awkward if/else-with-empty-branch in newRecapClient.
No behaviour change.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Sessions
8d8cf40beade View transcript
Changes
2
cmd/entire/cli
Mentireapi_client.go +13/-7
Mrecap.go +7/-8
27 unmodified lines
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
37 unmodified lines
88
89
90
82
83
84
85
91
92
93
94
27 unmodified lines
func runAuthenticatedActivityAPI(ctx context.Context, errW io.Writer, insecureHTTP bool, fn func(context.Context, *api.Client) error) error {
client, err := auth.NewEntireAPICellClient(ctx, insecureHTTP, nil)
if err != nil {
if !errors.Is(err, auth.ErrNoCellForJurisdiction) {
logging.Debug(ctx, "activity/recap: entire-api cell client unavailable, using data API", "error", err.Error())
}
logCellClientFallback(ctx, err)
return runAuthenticatedDataAPI(ctx, errW, insecureHTTP, fn)
}
return fn(ctx, client)
}
// logCellClientFallback records, at debug, that an activity/recap command fell back from the entire-api cell to the data API. The expected cases — the region has no cell yet, or the caller isn't logged in — aren't logged: they are normal during rollout and on first use, not diagnosable failures.
func logCellClientFallback(ctx context.Context, err error) {
if errors.Is(err, auth.ErrNoCellForJurisdiction) || errors.Is(err, auth.ErrNotLoggedIn) {
return
}
logging.Debug(ctx, "activity/recap: entire-api cell client unavailable, using data API", "error", err.Error())
}
// forgeToMirrorProvider maps a gitremote forge identifier (e.g. "gh") to the upstream provider the control plane records mirrors under (e.g. "github"). entire-api routing only supports GitHub mirrors today.
// and failed/suspended placements are skipped — they can't answer for the repo.
func firstActiveRepoID(mirrors []coreapi.Mirror) string {
for i := range mirrors {
if mirrors[i].IsArchived.Or(false) {
continue
}
if st := mirrors[i].Status.Or(coreapi.MirrorStatusReady); st == coreapi.MirrorStatusFailed || st == coreapi.MirrorStatusSuspended {
if !isActiveMirror(mirrors[i]) {
continue
}
if id := strings.TrimSpace(mirrors[i].MirrorId); id != "" {