diff --git a/changelog.d/fixed-observe-only-ok-to-test-warn.md b/changelog.d/fixed-observe-only-ok-to-test-warn.md new file mode 100644 index 0000000000..92fdd9c768 --- /dev/null +++ b/changelog.d/fixed-observe-only-ok-to-test-warn.md @@ -0,0 +1 @@ +- On a repo whose auto-merge is off, the contributor lane's observe-only pass no longer tries to post `/ok-to-test` on a non-member fork PR. Its mutation boundary refuses every write by design, and each pass runs on a fresh engine, so the attempt was refused and logged at WARN on every re-evaluation of the head, about every three minutes. diff --git a/src/pkg/github/automerge/automerge_contributor_prow_oktotest.go b/src/pkg/github/automerge/automerge_contributor_prow_oktotest.go index d5e37c711b..48e51f0af5 100644 --- a/src/pkg/github/automerge/automerge_contributor_prow_oktotest.go +++ b/src/pkg/github/automerge/automerge_contributor_prow_oktotest.go @@ -52,10 +52,20 @@ var prowTrustedAssociations = map[string]bool{ // remembered per repository (automerge_prow_refusal_memory.go), so a later // fork PR there gets the needs-human note without the command being posted. The caller // must already have admitted the PR to the contributor lane. +// +// An observe-only pass (a repo whose auto-merge is off) and the read-only +// eligibility probe post nothing here. Their mutation boundary refuses the +// comment by design, and each pass runs on a fresh engine whose per-head +// mark is empty, so the attempt was refused and logged at WARN on every +// re-evaluation of the head (projectbluefin/server#690, about every three +// minutes), as the workflow-fence audit comment once was (#17668). func (c *Engine) requestProwPresubmitsForFork(ctx context.Context, displayRepo, owner, repo string, pr *gh.PullRequest, number int, headSHA string) { if c == nil || c.gh == nil || pr == nil || strings.TrimSpace(headSHA) == "" || !c.isForkPR(pr) { return } + if c.observeOnly || integrationEligibilityProbe(ctx) { + return + } if prowTrustedAssociations[strings.ToUpper(strings.TrimSpace(pr.GetAuthorAssociation()))] { return } diff --git a/src/pkg/github/automerge/automerge_contributor_prow_oktotest_test.go b/src/pkg/github/automerge/automerge_contributor_prow_oktotest_test.go index 632b01bad6..f9912abb51 100644 --- a/src/pkg/github/automerge/automerge_contributor_prow_oktotest_test.go +++ b/src/pkg/github/automerge/automerge_contributor_prow_oktotest_test.go @@ -299,3 +299,32 @@ func TestContributorLaneProwRejectionAlreadyNotedLogsBelowWarn(t *testing.T) { t.Fatalf("WARN lines = %d in %q, want 1 (only the run that left the note)", got, logs.String()) } } + +// An observe-only pass (a repo whose auto-merge is off) posts no /ok-to-test +// and logs nothing at WARN: its mutation boundary refuses the comment by +// design, and each pass runs on a fresh engine, so the refused attempt was +// logged on every re-evaluation of the head (projectbluefin/server#690). The +// live sweep on the same fixture posts once (TestContributorLanePostsProwOkToTestForNonMemberFork). +func TestContributorLaneObserveOnlyPassDoesNotPostProwOkToTest(t *testing.T) { + fx := prowOkToTestFixture() + api := newContributorLaneAPI(t, &fx) + defer api.Close() + policy := defaultContributorLanePolicy() + clock := &contributorLaneClock{at: time.Date(2026, 11, 18, 10, 0, 0, 0, time.UTC)} + engine := newContributorLaneEngine(api.URL, policy, clock, Options{ContributorSoak: soakedTracker(clock)}) + var logs bytes.Buffer + for pass := 0; pass < 3; pass++ { + oc := engine.observeOnlyEngine() + oc.logger = slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelWarn})) + if _, _, err := oc.trySweepContributorLanePR(context.Background(), "widget", "acme", "widget", 7, policy); err != nil { + t.Fatalf("pass %d err = %v", pass, err) + } + clock.advance(workflowApprovalRecheck + time.Minute) + } + if fx.comments != 0 { + t.Fatalf("comments = %d %q, want none from an observe-only pass", fx.comments, fx.allComments) + } + if strings.Contains(logs.String(), "failed to post ok-to-test") { + t.Fatalf("observe-only pass logged the refused /ok-to-test at WARN: %s", logs.String()) + } +}