Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-hold-guard-stop-announce-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The hold guard now announces that it stopped keeping a held PR mergeable at INFO instead of WARN; several held fork PRs stopping in one pass no longer trips the `unclassified_error_repeated` self-report, and the person-facing note on the PR is unchanged (#17520).
29 changes: 25 additions & 4 deletions src/cmd/hive/hold_guard_update_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ func TestEnforceHoldGuardSettledUpdateIsNotDriftAtLift(t *testing.T) {
}

// A stop whose ledger entry was dropped and re-snapshotted (hold lifted, then
// returned) is announced at WARN once per head, base and reason, and its
// returned) is announced at INFO once per head, base and reason, and its
// person-facing note posted once per head and reason, not every pass.
func TestStopHeldPRUpdateWarnsAndNotesOncePerHeadAndBase(t *testing.T) {
var buf bytes.Buffer
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelWarn}))
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelInfo}))
store := newTestHoldGuardStore(t)
writer := &fakeIssueWriter{}
pr := github.PullRequest{Repo: "widgets", Number: 9016, HeadSHA: "once-h1", BaseSHA: "once-b1", MergeableState: "dirty", FromFork: true}
Expand Down Expand Up @@ -407,7 +407,7 @@ func TestStopHeldPRUpdateFreshStoreForgetsAnnouncedStops(t *testing.T) {
pr := github.PullRequest{Repo: "widgets", Number: 9017, HeadSHA: "fresh-h1", BaseSHA: "fresh-b1", MergeableState: "dirty", FromFork: true}
for i := 0; i < 2; i++ {
var buf bytes.Buffer
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelWarn}))
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelInfo}))
store := newTestHoldGuardStore(t)
writer := &fakeIssueWriter{}
store.Snapshot("acme/widgets", pr.Number, pr.HeadSHA, nil)
Expand All @@ -426,7 +426,7 @@ func TestStopHeldPRUpdateFreshStoreForgetsAnnouncedStops(t *testing.T) {
// (hivecommons/hive#16106).
func TestStopHeldPRUpdateMemoryBoundedPerPR(t *testing.T) {
var buf bytes.Buffer
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelWarn}))
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelInfo}))
store := newTestHoldGuardStore(t)
writer := &fakeIssueWriter{}
pr := github.PullRequest{Repo: "widgets", Number: 9018, HeadSHA: "bound-h1", MergeableState: "dirty", FromFork: true}
Expand Down Expand Up @@ -455,3 +455,24 @@ func TestStopHeldPRUpdateMemoryBoundedPerPR(t *testing.T) {
t.Fatalf("process memory holds %d entries for one PR, want 1", entries)
}
}

// The stop is an expected steady state already noted on the PR, so its first
// announcement is INFO: at WARN, several held PRs stopping in one pass collapse
// into one line repeated and trip unclassified_error_repeated (#17520).
func TestStopHeldPRUpdateAnnouncesAtInfoNotWarn(t *testing.T) {
var buf bytes.Buffer
logger := slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelDebug}))
store := newTestHoldGuardStore(t)
pr := github.PullRequest{Repo: "docs", Number: 9020, HeadSHA: "lvl-h1", BaseSHA: "lvl-b1", MergeableState: "dirty", FromFork: true}
store.Snapshot("acme/docs", pr.Number, pr.HeadSHA, nil)
stopHeldPRUpdate(context.Background(), &fakeIssueWriter{}, store, "acme/docs", pr, holdguard.UpdateStopForkNotEditable, nil, logger)
for _, line := range strings.Split(buf.String(), "\n") {
if strings.Contains(line, "stopped keeping held PR mergeable") {
if !strings.Contains(line, "level=INFO") {
t.Fatalf("stop announcement must be INFO, got: %s", line)
}
return
}
}
t.Fatalf("no stop announcement logged:\n%s", buf.String())
}
6 changes: 3 additions & 3 deletions src/cmd/hive/main_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ func maintainHeldPRMergeability(
}

// heldPRUpdateStopAnnounced remembers, for the life of the process, the
// held-PR update stop the guard last warned about and the person-facing note
// held-PR update stop the guard last announced and the person-facing note
// it last posted, per PR. The ledger carries both across restarts, but its
// entry can be dropped and re-snapshotted between passes (a hold that lifts
// and returns), losing the stop and the note together — without this the
// guard re-warned, and could re-post the note, every pass
// guard re-announced, and could re-post the note, every pass
// (hivecommons/hive#16103). Keyed on repo#pr with the last announced tuple as
// the value, so each held PR holds exactly one entry however often its head or
// base moves (hivecommons/hive#16106).
Expand Down Expand Up @@ -545,7 +545,7 @@ func stopHeldPRUpdate(ctx context.Context, writer forge.IssueWriter, store *hold
} else {
st.warnHead, st.warnBase, st.warnReason = pr.HeadSHA, pr.BaseSHA, reason
heldPRUpdateStopAnnounced.Store(stopKey, st)
logger.Warn("hold guard: stopped keeping held PR mergeable until its head or base moves", args...)
logger.Info("hold guard: stopped keeping held PR mergeable until its head or base moves", args...)
}
noteHeldPRUpdateStopped(ctx, writer, store, repo, pr, reason, logger)
}
Expand Down
Loading