Skip to content

Commit d30dc67

Browse files
aparajonclaude
andcommitted
refactor(github): follow the merge gate rename through the preflight fan-out
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7d2e4db commit d30dc67

4 files changed

Lines changed: 408 additions & 397 deletions

File tree

pkg/metrics/metrics.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,47 +1512,47 @@ func RecordPendingDropsCleanupError(ctx context.Context, database, environment,
15121512
)
15131513
}
15141514

1515-
// Check refresh recording sources for RecordCheckRefreshRecorded.
1515+
// Merge gate recording sources for RecordMergeGateRecorded.
15161516
const (
1517-
// CheckRefreshSourceDriveTail marks a request recorded inline by the
1517+
// MergeGateSourceDriveTail marks a request recorded inline by the
15181518
// operator drive tail that settled the apply.
1519-
CheckRefreshSourceDriveTail = "drive_tail"
1520-
// CheckRefreshSourceSweep marks a request recorded by the backstop sweep
1519+
MergeGateSourceDriveTail = "drive_tail"
1520+
// MergeGateSourceSweep marks a request recorded by the backstop sweep
15211521
// over recently completed applies.
1522-
CheckRefreshSourceSweep = "sweep"
1523-
// CheckRefreshSourceReleaseSweep marks a settle request backfilled by the
1522+
MergeGateSourceSweep = "sweep"
1523+
// MergeGateSourceReleaseSweep marks a settle request backfilled by the
15241524
// sweep over terminal applies whose preflight held sibling checks but
15251525
// whose settle was never recorded.
1526-
CheckRefreshSourceReleaseSweep = "release_sweep"
1526+
MergeGateSourceReleaseSweep = "release_sweep"
15271527
)
15281528

1529-
// RecordCheckRefreshRecorded counts durable check refresh requests recorded
1529+
// RecordMergeGateRecorded counts durable merge gate requests recorded
15301530
// when an apply settles to terminal success. A sustained "sweep" rate means
15311531
// drive tails are failing to record — check the operator logs for the
15321532
// recording error.
1533-
func RecordCheckRefreshRecorded(ctx context.Context, database, environment, source string) {
1534-
addCounter(ctx, "schemabot.check_refresh.requests_recorded_total",
1535-
"Total durable check refresh requests recorded for applies that settled to terminal success", "{request}",
1533+
func RecordMergeGateRecorded(ctx context.Context, database, environment, source string) {
1534+
addCounter(ctx, "schemabot.merge_gate.requests_recorded_total",
1535+
"Total durable merge gate requests recorded for applies that settled to terminal success", "{request}",
15361536
attribute.String("database", database),
15371537
EnvironmentAttribute(environment),
15381538
attribute.String("source", source),
15391539
)
15401540
}
15411541

1542-
// RecordCheckRefreshRecordFailure counts failures to record a durable check
1543-
// refresh request for a completed apply. The backstop sweep retries the
1542+
// RecordMergeGateRecordFailure counts failures to record a durable merge
1543+
// gate request for a completed apply. The backstop sweep retries the
15441544
// recording on its next pass, so a transient blip self-heals; a sustained rate
15451545
// means storage writes are failing and sibling PR checks are going stale —
15461546
// check the operator logs for the storage error.
1547-
func RecordCheckRefreshRecordFailure(ctx context.Context, database, environment string) {
1548-
addCounter(ctx, "schemabot.check_refresh.record_failures_total",
1549-
"Total failures to record a durable check refresh request for a completed apply", "{failure}",
1547+
func RecordMergeGateRecordFailure(ctx context.Context, database, environment string) {
1548+
addCounter(ctx, "schemabot.merge_gate.record_failures_total",
1549+
"Total failures to record a durable merge gate request for a completed apply", "{failure}",
15501550
attribute.String("database", database),
15511551
EnvironmentAttribute(environment),
15521552
)
15531553
}
15541554

1555-
// RecordCheckRefreshPROutcome counts per-PR outcomes of check refresh fan-out.
1555+
// RecordMergeGatePROutcome counts per-PR outcomes of merge gate fan-out.
15561556
// Outcomes:
15571557
// - "refreshed": the PR's stored check state was re-planned against the
15581558
// mutated target schema.
@@ -1568,41 +1568,41 @@ func RecordCheckRefreshRecordFailure(ctx context.Context, database, environment
15681568
// - "skipped_superseded": a racing write (a synchronize that re-planned a
15691569
// newer head, or an apply that claimed the row) landed first and is
15701570
// authoritative; the refresh yielded to it.
1571-
func RecordCheckRefreshPROutcome(ctx context.Context, repository, database, environment, outcome string) {
1572-
addCounter(ctx, "schemabot.check_refresh.pr_refreshes_total",
1573-
"Total per-PR outcomes of check refresh fan-out after a target schema changed", "{refresh}",
1571+
func RecordMergeGatePROutcome(ctx context.Context, repository, database, environment, outcome string) {
1572+
addCounter(ctx, "schemabot.merge_gate.pr_refreshes_total",
1573+
"Total per-PR outcomes of merge gate fan-out after a target schema changed", "{refresh}",
15741574
attribute.String("repository", repository),
15751575
attribute.String("database", database),
15761576
EnvironmentAttribute(environment),
15771577
attribute.String("outcome", outcome),
15781578
)
15791579
}
15801580

1581-
// RecordCheckRefreshEventOutcome counts terminal outcomes of driving one
1582-
// durable check refresh request. Outcomes:
1581+
// RecordMergeGateEventOutcome counts terminal outcomes of driving one
1582+
// durable merge gate request. Outcomes:
15831583
// - "completed": the fan-out refreshed (or safely skipped) every sibling PR.
15841584
// - "failed_retrying": the fan-out failed and the request will be retried.
15851585
// - "failed_terminal": the fan-out failed on its final attempt — sibling PR
15861586
// stored checks for the target may remain stale until their PRs re-plan.
15871587
// Check the server logs for the failing PR and re-plan it.
15881588
// - "lease_lost": the drive lost its lease mid-fan-out; another driver
15891589
// re-drives the request (re-planning the same PRs again is safe).
1590-
func RecordCheckRefreshEventOutcome(ctx context.Context, database, environment, outcome string) {
1591-
addCounter(ctx, "schemabot.check_refresh.events_total",
1592-
"Total terminal outcomes of driving durable check refresh requests", "{event}",
1590+
func RecordMergeGateEventOutcome(ctx context.Context, database, environment, outcome string) {
1591+
addCounter(ctx, "schemabot.merge_gate.events_total",
1592+
"Total terminal outcomes of driving durable merge gate requests", "{event}",
15931593
attribute.String("database", database),
15941594
EnvironmentAttribute(environment),
15951595
attribute.String("outcome", outcome),
15961596
)
15971597
}
15981598

1599-
// RecordCheckRefreshTerminatedStuck counts check refresh requests terminated
1599+
// RecordMergeGateTerminatedStuck counts merge gate requests terminated
16001600
// by the stuck-processing sweep: rows wedged past the attempt cap with an
16011601
// expired lease (a driver hard-killed on its final attempt). Each terminated
16021602
// request means sibling PR stored checks for its target may remain stale —
16031603
// find the request's target in the server logs and re-plan the affected PRs.
1604-
func RecordCheckRefreshTerminatedStuck(ctx context.Context, terminated int64) {
1605-
addCounterN(ctx, terminated, "schemabot.check_refresh.terminated_stuck_total",
1606-
"Total check refresh requests terminated by the stuck-processing sweep", "{request}",
1604+
func RecordMergeGateTerminatedStuck(ctx context.Context, terminated int64) {
1605+
addCounterN(ctx, terminated, "schemabot.merge_gate.terminated_stuck_total",
1606+
"Total merge gate requests terminated by the stuck-processing sweep", "{request}",
16071607
)
16081608
}

pkg/webhook/handler.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ type Handler struct {
173173
webhookReconcileGrace time.Duration
174174
webhookReconcileMaxPages int
175175

176-
// Check refresh processor lifecycle (see check_refresh.go). The intervals
176+
// Merge gate processor lifecycle (see merge_gate.go). The intervals
177177
// have package defaults set at construction; tests override them directly.
178-
checkRefreshPollInterval time.Duration
179-
checkRefreshLeaseDuration time.Duration
180-
checkRefreshSweepLookback time.Duration
181-
checkRefreshMu sync.Mutex
182-
checkRefreshStop chan struct{}
183-
checkRefreshCancel context.CancelFunc
184-
checkRefreshWg sync.WaitGroup
185-
// checkRefreshKick wakes the driver to run a pass now instead of waiting
178+
mergeGatePollInterval time.Duration
179+
mergeGateLeaseDuration time.Duration
180+
mergeGateSweepLookback time.Duration
181+
mergeGateMu sync.Mutex
182+
mergeGateStop chan struct{}
183+
mergeGateCancel context.CancelFunc
184+
mergeGateWg sync.WaitGroup
185+
// mergeGateKick wakes the driver to run a pass now instead of waiting
186186
// for the next poll tick; buffered so one pending kick coalesces any
187187
// number of concurrent recordings.
188-
checkRefreshKick chan struct{}
188+
mergeGateKick chan struct{}
189189

190190
logger *slog.Logger
191191
priorEnvCheckMaxAttempts int
@@ -272,10 +272,10 @@ func NewHandlerWithDispatch(service *api.Service, ghClients github.ClientSet, we
272272
webhookReconcileLookback: defaultWebhookReconcileLookback,
273273
webhookReconcileGrace: defaultWebhookReconcileGrace,
274274
webhookReconcileMaxPages: defaultWebhookReconcileMaxPages,
275-
checkRefreshPollInterval: defaultCheckRefreshPollInterval,
276-
checkRefreshLeaseDuration: defaultCheckRefreshLeaseDuration,
277-
checkRefreshSweepLookback: defaultCheckRefreshSweepLookback,
278-
checkRefreshKick: make(chan struct{}, 1),
275+
mergeGatePollInterval: defaultMergeGatePollInterval,
276+
mergeGateLeaseDuration: defaultMergeGateLeaseDuration,
277+
mergeGateSweepLookback: defaultMergeGateSweepLookback,
278+
mergeGateKick: make(chan struct{}, 1),
279279
priorEnvCheckMaxAttempts: defaultPriorEnvCheckMaxAttempts,
280280
priorEnvCheckRetryInterval: defaultPriorEnvCheckRetryInterval,
281281
}

0 commit comments

Comments
 (0)