From d0d1f1695b1e7a062cf80f9974d6a20c2e8b9e4a Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 00:46:57 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20hold=20guard:=20announce=20a=20s?= =?UTF-8?q?topped=20held-PR=20update=20at=20INFO=20instead=20of=20WARN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-hold-guard-stop-announce-info.md | 1 + src/cmd/hive/hold_guard_update_retry_test.go | 29 ++++++++++++++++--- src/cmd/hive/main_helpers.go | 6 ++-- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 changelog.d/fixed-hold-guard-stop-announce-info.md diff --git a/changelog.d/fixed-hold-guard-stop-announce-info.md b/changelog.d/fixed-hold-guard-stop-announce-info.md new file mode 100644 index 0000000000..ceca66cf79 --- /dev/null +++ b/changelog.d/fixed-hold-guard-stop-announce-info.md @@ -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). diff --git a/src/cmd/hive/hold_guard_update_retry_test.go b/src/cmd/hive/hold_guard_update_retry_test.go index 96f44ae87c..9992b3de40 100644 --- a/src/cmd/hive/hold_guard_update_retry_test.go +++ b/src/cmd/hive/hold_guard_update_retry_test.go @@ -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} @@ -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) @@ -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} @@ -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()) +} diff --git a/src/cmd/hive/main_helpers.go b/src/cmd/hive/main_helpers.go index 4e71fdc316..29567b0b07 100644 --- a/src/cmd/hive/main_helpers.go +++ b/src/cmd/hive/main_helpers.go @@ -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). @@ -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) }