Skip to content

Ignore non-created issue comment events in prow plugins#5170

Open
petr-muller wants to merge 4 commits intoopenshift:mainfrom
petr-muller:pj-rehearse-edits
Open

Ignore non-created issue comment events in prow plugins#5170
petr-muller wants to merge 4 commits intoopenshift:mainfrom
petr-muller:pj-rehearse-edits

Conversation

@petr-muller
Copy link
Copy Markdown
Member

@petr-muller petr-muller commented May 9, 2026

Summary

Several custom prow plugins (payload-testing, multi-pr-prow-plugin, backport-verifier, pipeline-controller) process all IssueCommentEvent actions, including edited and deleted. This means editing a comment containing a slash command (e.g. /payload-job) unintentionally re-triggers the action.

Add an early return for non-created actions in each plugin's handleIssueComment, matching what pj-rehearse already does.

🤖 Generated with Claude Code

This PR makes four custom Prow plugins ignore IssueCommentEvent actions other than "created", preventing edited or deleted comments from re-triggering slash-command processing.

What changed in practice

  • Each plugin's issue-comment handler now returns early unless ic.Action == github.IssueCommentActionCreated. Only newly created comments containing slash commands will be parsed and acted on.
  • Unit tests were added/expanded for each plugin to assert that edited and deleted comment events do not trigger actions (no comments posted, no prow jobs scheduled, etc.).

Components affected and behavior changes

  • payload-testing-prow-plugin: Only newly created comments will trigger /payload, /payload-job, /payload-with-prs, /payload-job-with-prs, /payload-aggregate, /payload-aggregate-with-prs and /payload-abort handling. Editing or deleting a comment with a payload command will no longer re-run or re-schedule payload jobs.
  • multi-pr-prow-plugin: Only newly created comments will trigger /testwith and /testwith abort flows; edits/deletes will be ignored and will not schedule or abort multi-PR ProwJobs.
  • backport-verifier: Only newly created comments will trigger /validate-backports. Edited or deleted comments will not re-run backport validation or post validation comments/labels.
  • pipeline-controller: Only newly created comments will trigger /pipeline commands (e.g., /pipeline required, /pipeline auto). As a minor efficiency improvement, ignored events now return before acquiring the controller’s mutex, reducing unnecessary lock contention.

Impact for CI users and operators

  • Editing or deleting a comment that contains a slash command will no longer accidentally re-trigger CI actions or create redundant noise.
  • Reduces unnecessary job runs and spurious comments; improves predictability of slash-command-triggered behavior.
  • New unit tests across the plugins help prevent regressions.

Copilot AI review requested due to automatic review settings May 9, 2026 00:59
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: bee76c37-208f-421a-84e6-a94f6426a685

📥 Commits

Reviewing files that changed from the base of the PR and between 9e7bd71 and 8038421.

📒 Files selected for processing (2)
  • cmd/pipeline-controller/main.go
  • cmd/pipeline-controller/main_test.go
✅ Files skipped from review due to trivial changes (1)
  • cmd/pipeline-controller/main_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/pipeline-controller/main.go

📝 Walkthrough

Walkthrough

Issue-comment handlers in multiple commands now ignore all GitHub issue comment event actions except created, so comment-based command parsing only runs for newly created comments.

Changes

Cohort / File(s) Summary
Handler Guard Clauses
cmd/backport-verifier/server.go, cmd/multi-pr-prow-plugin/server.go, cmd/payload-testing-prow-plugin/server.go, cmd/pipeline-controller/main.go
Each handleIssueComment now returns early unless e.Action == github.IssueCommentActionCreated, preventing processing on edited/deleted/other comment events.
Tests
cmd/backport-verifier/server_test.go, cmd/multi-pr-prow-plugin/server_test.go, cmd/payload-testing-prow-plugin/server_test.go, cmd/pipeline-controller/main_test.go
Added or extended unit tests asserting that non-created actions (edited, deleted) do not trigger command parsing, comment creation, or job reporting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 13 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Ignore non-created issue comment events in prow plugins' directly and accurately summarizes the main change: adding early returns to skip processing non-created actions across multiple plugins.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Go Error Handling ✅ Passed PR changes are simple control flow early returns with no new error handling code. Existing error handling in the codebase uses proper fmt.Errorf with %w wrapping and checks errors correctly.
Test Coverage For New Features ✅ Passed Test coverage present. New test functions added for plugins and pipeline-controller test extended. All tests verify edited/deleted actions ignored.
Stable And Deterministic Test Names ✅ Passed Test names are stable and deterministic. No dynamic content, timestamps, UUIDs, or generated identifiers in test titles.
Test Structure And Quality ✅ Passed Custom check for Ginkgo tests not applicable to this PR. Tests use standard Go testing package, not Ginkgo, with focused assertions and meaningful error messages.
Microshift Test Compatibility ✅ Passed This PR adds only standard Go unit tests (testing.T), not Ginkgo e2e tests. The check is specific to Ginkgo e2e tests and is not applicable here.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Check not applicable. This PR adds only standard Go unit tests (testing.T), not Ginkgo e2e tests. The SNO compatibility check applies only to Ginkgo e2e test additions.
Topology-Aware Scheduling Compatibility ✅ Passed This PR only modifies Prow plugin event handlers that process GitHub issue comments. No Kubernetes deployment manifests, scheduling constraints, affinity rules, or pod specifications are added.
Ote Binary Stdout Contract ✅ Passed These are Prow webhook plugins, not OTE binaries. Changes add early returns to handleIssueComment methods registered as event callbacks. No process-level code modified, no stdout writes introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR contains only unit tests using Go's testing package, not Ginkgo e2e tests. The check applies to new Ginkgo e2e tests (It(), Describe(), Context(), When()), which are not present here.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from jmguzik and psalajova May 9, 2026 00:59
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 9, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: petr-muller
Once this PR has been reviewed and has the lgtm label, please assign jmguzik for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents several custom Prow plugins from re-processing slash commands when an existing GitHub issue/PR comment is edited or deleted, by early-returning unless the IssueCommentEvent action is created (matching the existing pj-rehearse behavior).

Changes:

  • Add IssueCommentActionCreated guards to ignore non-created IssueCommentEvent actions in multiple plugins.
  • Ensure slash-command handlers only run on newly created comments (avoids accidental re-triggers on edits/deletes).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
cmd/pipeline-controller/main.go Ignore non-created issue comment events before running pipeline slash-command handling.
cmd/payload-testing-prow-plugin/server.go Ignore non-created issue comment events before processing payload-testing commands.
cmd/multi-pr-prow-plugin/server.go Ignore non-created issue comment events before processing /testwith commands.
cmd/backport-verifier/server.go Ignore non-created issue comment events before processing /validate-backports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/pipeline-controller/main.go
Comment thread cmd/payload-testing-prow-plugin/server.go
Comment thread cmd/multi-pr-prow-plugin/server.go
Comment thread cmd/backport-verifier/server.go
@petr-muller petr-muller force-pushed the pj-rehearse-edits branch from f72453f to 1dab8b7 Compare May 9, 2026 01:13
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
cmd/payload-testing-prow-plugin/server_test.go (1)

1400-1434: ⚡ Quick win

Verify Kubernetes-side effects are also zero.

At Line 1428 you only assert no GitHub comments. Please also assert that no PullRequestPayloadQualificationRun objects are created for edited/deleted actions.

Proposed test extension
+import (
+    ...
+    ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
+)
...
 	for _, action := range []github.IssueCommentEventAction{github.IssueCommentActionEdited, github.IssueCommentActionDeleted} {
 		t.Run(string(action), func(t *testing.T) {
 			ghc.IssueCommentsAdded = nil
 			s.handleIssueComment(logrus.WithField("test", t.Name()), github.IssueCommentEvent{
 				Action: action,
 				Repo:   github.Repo{Owner: github.User{Login: "openshift"}},
 				Issue: github.Issue{
 					Number:      123,
 					PullRequest: &struct{}{},
 				},
 				Comment: github.IssueComment{
 					Body: "/payload 4.10 nightly informing",
 				},
 			})
 			if len(ghc.IssueCommentsAdded) > 0 {
 				t.Errorf("expected no comments for %s action, got: %v", action, ghc.IssueCommentsAdded)
 			}
+			var runs prpqv1.PullRequestPayloadQualificationRunList
+			if err := s.kubeClient.List(context.TODO(), &runs, &ctrlruntimeclient.ListOptions{Namespace: "ci"}); err != nil {
+				t.Fatalf("failed to list payload runs: %v", err)
+			}
+			if len(runs.Items) > 0 {
+				t.Errorf("expected no payload runs for %s action, got: %d", action, len(runs.Items))
+			}
 		})
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/payload-testing-prow-plugin/server_test.go` around lines 1400 - 1434,
Extend TestHandleIssueCommentIgnoresNonCreatedActions to also assert no
Kubernetes PullRequestPayloadQualificationRun objects are created when actions
are edited/deleted: after calling s.handleIssueComment, use the server's
kubeClient (s.kubeClient) to List PullRequestPayloadQualificationRun objects
(type PullRequestPayloadQualificationRun) in namespace s.namespace and assert
the returned list is empty (length==0); do this inside the t.Run subtest
alongside the existing ghc.IssueCommentsAdded check so both GitHub and K8s
side-effects are verified for the non-created actions.
cmd/backport-verifier/server_test.go (1)

79-108: ⚡ Quick win

Also assert labels remain unchanged for non-created actions.

At Line 103 only comments are checked. Since this path should be a no-op, please also assert no labels were added/removed.

Proposed assertion
 			if len(client.comments[orp]) > 0 {
 				t.Errorf("expected no comments for %s action, got: %v", action, client.comments[orp])
 			}
+			if len(client.labels[orp]) > 0 {
+				t.Errorf("expected no labels for %s action, got: %v", action, client.labels[orp])
+			}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/backport-verifier/server_test.go` around lines 79 - 108, The test
TestHandleIssueCommentIgnoresNonCreatedActions currently only asserts no
comments were added for non-created actions; also assert labels remain unchanged
by checking fakeClient.labels[orp] is empty (or equal to its initial value)
after calling server.handleIssueComment. Locate the orprepopr variable (orp),
the fakeClient with labels map, and add an assertion similar to the comments
check that len(client.labels[orp]) == 0 (or compare slices) to ensure
handleIssueComment is a no-op for edited/deleted actions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/multi-pr-prow-plugin/server_test.go`:
- Around line 399-424: The test TestHandleIssueCommentIgnoresNonCreatedActions
currently calls s.handleIssueComment but asserts nothing; change the test to
verify no side effects occur by using a recording fakeReporter (or extend
fakeReporter) and asserting it recorded zero reports after each call, assert the
fakeGithubClient (fakeGithubClient) recorded no API interactions, and assert the
fake Kubernetes client (created by fakectrlruntimeclient.NewFakeClient()) has no
created ProwJob or related resources; perform these zero-call/empty-state
assertions inside the t.Run subtest after invoking server.handleIssueComment to
ensure non-created actions produce no work.

---

Nitpick comments:
In `@cmd/backport-verifier/server_test.go`:
- Around line 79-108: The test TestHandleIssueCommentIgnoresNonCreatedActions
currently only asserts no comments were added for non-created actions; also
assert labels remain unchanged by checking fakeClient.labels[orp] is empty (or
equal to its initial value) after calling server.handleIssueComment. Locate the
orprepopr variable (orp), the fakeClient with labels map, and add an assertion
similar to the comments check that len(client.labels[orp]) == 0 (or compare
slices) to ensure handleIssueComment is a no-op for edited/deleted actions.

In `@cmd/payload-testing-prow-plugin/server_test.go`:
- Around line 1400-1434: Extend TestHandleIssueCommentIgnoresNonCreatedActions
to also assert no Kubernetes PullRequestPayloadQualificationRun objects are
created when actions are edited/deleted: after calling s.handleIssueComment, use
the server's kubeClient (s.kubeClient) to List
PullRequestPayloadQualificationRun objects (type
PullRequestPayloadQualificationRun) in namespace s.namespace and assert the
returned list is empty (length==0); do this inside the t.Run subtest alongside
the existing ghc.IssueCommentsAdded check so both GitHub and K8s side-effects
are verified for the non-created actions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 8c1a8513-93da-4880-9136-c89265a2ac4b

📥 Commits

Reviewing files that changed from the base of the PR and between eaf2db7 and f72453f.

📒 Files selected for processing (4)
  • cmd/backport-verifier/server_test.go
  • cmd/multi-pr-prow-plugin/server_test.go
  • cmd/payload-testing-prow-plugin/server_test.go
  • cmd/pipeline-controller/main_test.go
✅ Files skipped from review due to trivial changes (1)
  • cmd/pipeline-controller/main_test.go

Comment thread cmd/multi-pr-prow-plugin/server_test.go
petr-muller and others added 3 commits May 9, 2026 03:16
The handler processed all IssueCommentEvent actions (created, edited,
deleted), which meant editing a comment containing a /payload-job command
would unintentionally re-trigger the payload job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The handler processed all IssueCommentEvent actions (created, edited,
deleted), which meant editing a comment containing a /testwith command
would unintentionally re-trigger the job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The handler processed all IssueCommentEvent actions (created, edited,
deleted), which meant editing a comment containing a /validate-backports
command would unintentionally re-trigger the verification.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@petr-muller petr-muller force-pushed the pj-rehearse-edits branch from 1dab8b7 to 9e7bd71 Compare May 9, 2026 01:16
Copilot AI review requested due to automatic review settings May 9, 2026 01:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread cmd/pipeline-controller/main_test.go
@petr-muller
Copy link
Copy Markdown
Member Author

/retest-required

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification

No second-stage tests were triggered for this PR.

This can happen when:

  • The changed files don't match any pipeline_run_if_changed patterns
  • All files match pipeline_skip_if_only_changed patterns
  • No pipeline-controlled jobs are defined for the main branch

Use /test ? to see all available tests.

The handler processed all IssueCommentEvent actions (created, edited,
deleted), which meant editing a comment containing a /pipeline command
would unintentionally re-trigger the pipeline. Also avoids taking the
mutex lock for events that will be ignored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@petr-muller petr-muller force-pushed the pj-rehearse-edits branch from 9e7bd71 to 8038421 Compare May 9, 2026 23:46
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 10, 2026

@petr-muller: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/images 8038421 link true /test images
ci/prow/breaking-changes 8038421 link false /test breaking-changes

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants