Skip to content

prowgen: allow per-test slack reporter config in ci-operator config#5149

Open
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:prowgen-slack-reporter
Open

prowgen: allow per-test slack reporter config in ci-operator config#5149
Prucek wants to merge 1 commit intoopenshift:mainfrom
Prucek:prowgen-slack-reporter

Conversation

@Prucek
Copy link
Copy Markdown
Member

@Prucek Prucek commented Apr 30, 2026

Summary

  • Adds a reporter_config field to TestStepConfiguration so ci-operator config files can specify Slack notifications directly on individual tests
  • Per-test config takes precedence over .config.prowgen slack_reporter, which remains as fallback during the migration
  • Applies defaults when not specified: job_states_to_report: [success, failure, error] and a standard report template matching the most common pattern in the release repo
  • slackReporterConfig() returns *prowv1.ReporterConfig instead of mutating the job base
  • For periodic tests with presubmit: true, the presubmit job does not get the slack config by default — set report_presubmit: true on the reporter config to include it
  • Adds validation: channel is required, report_presubmit can only be set when presubmit: true
  • Part of the incremental .config.prowgen deprecation

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Slack notifications for CI jobs: Report job states (success, failure, error) to Slack channels with customizable message templates.
    • Per-job Slack configuration: Enable reporting independently for different job types (periodic, presubmit, postsubmit).
  • Tests

    • Added integration test configurations demonstrating Slack reporting across multiple job scenarios.

@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 Apr 30, 2026

📝 Walkthrough

Walkthrough

Adds Slack reporter configuration types and defaults to the API, threads per-test Slack reporter settings through prowgen job generation (periodic/presubmit/postsubmit) with presubmit gating, updates validation to enforce reporter constraints, and adds integration test input/output YAMLs exercising the behavior.

Changes

Cohort / File(s) Summary
API Type Definitions
pkg/api/types.go
Add SlackReporterConfig type, exported defaults DefaultSlackReporterJobStatesToReport and DefaultSlackReporterReportTemplate, and add SlackReporterConfig *SlackReporterConfig \json:"reporter_config,omitempty"`toTestStepConfiguration`.
Prowgen logic
pkg/prowgen/prowgen.go
Replace mutating helper with pure slackReporterConfig(...) that returns *prowv1.ReporterConfig; thread per-test cioperatorapi.SlackReporterConfig through generation paths, apply defaults or fall back to global config, implement presubmit-from-periodic gating, and assign base.ReporterConfig at call sites.
Validation
pkg/validation/test.go
Enforce that when SlackReporterConfig is present the channel is set and report_presubmit: true is only allowed for presubmit tests; append validation errors accordingly.
Integration test input
test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml
Add CI-Operator config with multiple test steps including inline reporter_config entries (channel, job-states, template, report_presubmit) to exercise per-test Slack settings.
Generated Prow job outputs
test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/...-presubmits.yaml, ...-postsubmits.yaml, ...-periodics.yaml
Add generated presubmit/postsubmit/periodic job YAMLs that reflect per-test Slack reporter settings and templates; include periodic-only gating and appropriate reporter state lists.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 12 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Coverage For New Features ⚠️ Warning New SlackReporterConfig type and slackReporterConfig function lack unit test coverage in their respective test files. Add unit tests for SlackReporterConfig initialization, exported defaults, and the slackReporterConfig function with table-driven test cases.
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding per-test Slack reporter configuration support to ci-operator config files via the prowgen tool.
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 Pull request follows proper Go error handling patterns with appropriate error wrapping, nil checks, and no unjustified ignored errors.
Stable And Deterministic Test Names ✅ Passed This PR does not introduce or modify any Ginkgo test declarations with unstable or non-deterministic test names.
Test Structure And Quality ✅ Passed PR contains no Ginkgo test code (*_test.go files with Describe/It patterns); custom check for test quality is not applicable.
Microshift Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests; modified files are library and validation code for CI operator tooling.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests. Modified files contain API definitions, job generation logic, and validation code—not e2e test implementations.
Topology-Aware Scheduling Compatibility ✅ Passed PR adds Slack reporter configuration for CI/CD test jobs without introducing pod affinity, scheduling constraints, or topology-dependent logic affecting production deployments.
Ote Binary Stdout Contract ✅ Passed PR modifies only library packages with type definitions and helper functions, not OTE binary code or process-level entry points.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests. Changes consist entirely of infrastructure and configuration code with no executable e2e tests.

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

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

Warning

Review ran into problems

🔥 Problems

Linked repositories: Couldn't analyze openshift/ci-docs - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
fatal: unable to access 'https://github.com/openshift/ci-docs.git/': Failed to connect to github.com port 443 after 133565 ms: Couldn't connect to server


Linked repositories: Couldn't analyze openshift/release - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
fatal: unable to access 'https://github.com/openshift/release.git/': Failed to connect to github.com port 443 after 134812 ms: Couldn't connect to server


Linked repositories: Couldn't analyze openshift/release-controller - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
fatal: unable to access 'https://github.com/openshift/release-controller.git/': Failed to connect to github.com port 443 after 133399 ms: Couldn't connect to server


Linked repositories: Couldn't analyze openshift/ci-chat-bot - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
fatal: unable to access 'https://github.com/openshift/ci-chat-bot.git/': Failed to connect to github.com port 443 after 133536 ms: Couldn't connect to server


Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Prucek

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

The pull request process is described 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 30, 2026
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e

@Prucek Prucek force-pushed the prowgen-slack-reporter branch from 0dc3372 to 978d30b Compare April 30, 2026 12:01
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/prowgen/prowgen.go`:
- Around line 269-285: The code treats any matching testSlackConfig as
authoritative even when its Channel is empty, causing the fallback config to be
skipped; modify the conditional to require a non-empty testSlackConfig.Channel
(or explicitly check for Channel == "") before returning so that if Channel is
empty you continue to the legacy .config.prowgen fallback; adjust the block
around slackConfigAppliesToJobType(testSlackConfig, jobType) to only construct
and return a prowv1.ReporterConfig with SlackReporterConfig when
testSlackConfig.Channel is non-empty (while still applying the existing defaults
cioperatorapi.DefaultSlackReporterJobStatesToReport and
cioperatorapi.DefaultSlackReporterReportTemplate).
🪄 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: 0d6c9bbc-65b8-42e2-97b9-8bb090d522bb

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc3372 and 978d30b.

⛔ Files ignored due to path filters (2)
  • pkg/api/zz_generated.deepcopy.go is excluded by !**/zz_generated*
  • pkg/webreg/zz_generated.ci_operator_reference.go is excluded by !**/zz_generated*
📒 Files selected for processing (6)
  • pkg/api/types.go
  • pkg/prowgen/prowgen.go
  • test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-periodics.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-postsubmits.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-presubmits.yaml
✅ Files skipped from review due to trivial changes (1)
  • test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-presubmits.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-postsubmits.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-periodics.yaml

Comment thread pkg/prowgen/prowgen.go Outdated
Comment on lines +269 to +285
if testSlackConfig != nil && slackConfigAppliesToJobType(testSlackConfig, jobType) {
jobStatesToReport := testSlackConfig.JobStatesToReport
if len(jobStatesToReport) == 0 {
jobStatesToReport = cioperatorapi.DefaultSlackReporterJobStatesToReport
}
reportTemplate := testSlackConfig.ReportTemplate
if reportTemplate == "" {
reportTemplate = cioperatorapi.DefaultSlackReporterReportTemplate
}
return &prowv1.ReporterConfig{
Slack: &prowv1.SlackReporterConfig{
Channel: testSlackConfig.Channel,
JobStatesToReport: jobStatesToReport,
ReportTemplate: reportTemplate,
},
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t let an empty per-test channel suppress the legacy fallback.

Line 269 treats any matching per-test reporter_config as authoritative, even when channel is empty. That skips .config.prowgen fallback and generates jobs with a broken Slack reporter during migration.

Suggested fix
-func slackReporterConfig(jobName, testName string, jobType prowv1.ProwJobType, testSlackConfig *cioperatorapi.SlackReporterConfig, info *ProwgenInfo) *prowv1.ReporterConfig {
-	if testSlackConfig != nil && slackConfigAppliesToJobType(testSlackConfig, jobType) {
+func slackReporterConfig(jobName, testName string, jobType prowv1.ProwJobType, testSlackConfig *cioperatorapi.SlackReporterConfig, info *ProwgenInfo) *prowv1.ReporterConfig {
+	if testSlackConfig != nil && slackConfigAppliesToJobType(testSlackConfig, jobType) && testSlackConfig.Channel != "" {
 		jobStatesToReport := testSlackConfig.JobStatesToReport
 		if len(jobStatesToReport) == 0 {
 			jobStatesToReport = cioperatorapi.DefaultSlackReporterJobStatesToReport
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/prowgen/prowgen.go` around lines 269 - 285, The code treats any matching
testSlackConfig as authoritative even when its Channel is empty, causing the
fallback config to be skipped; modify the conditional to require a non-empty
testSlackConfig.Channel (or explicitly check for Channel == "") before returning
so that if Channel is empty you continue to the legacy .config.prowgen fallback;
adjust the block around slackConfigAppliesToJobType(testSlackConfig, jobType) to
only construct and return a prowv1.ReporterConfig with SlackReporterConfig when
testSlackConfig.Channel is non-empty (while still applying the existing defaults
cioperatorapi.DefaultSlackReporterJobStatesToReport and
cioperatorapi.DefaultSlackReporterReportTemplate).

@Prucek Prucek force-pushed the prowgen-slack-reporter branch from 978d30b to f7fadaf Compare April 30, 2026 12:21
Add a `reporter_config` field to `TestStepConfiguration` that lets
ci-operator config files specify Slack notifications directly on
individual tests, with an optional `job_types` filter to control which
generated job types (presubmit/postsubmit/periodic) receive the config.

Per-test config takes precedence over `.config.prowgen` slack_reporter,
which remains as a fallback during the migration period.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Prucek Prucek force-pushed the prowgen-slack-reporter branch from f7fadaf to 70184f0 Compare April 30, 2026 12:24
@Prucek
Copy link
Copy Markdown
Member Author

Prucek commented Apr 30, 2026

/test e2e

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/prowgen/prowgen.go (1)

227-243: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t use nil to mean “suppress Slack completely” for periodic-derived presubmits.

Line 229 clears the inline config, but Line 312 still routes through slackReporterConfig(...), and nil there falls through to .config.prowgen on Lines 290-297. So a periodic test with presubmit: true can still inherit the legacy fallback reporter even when report_presubmit is false or unset, which breaks the new migration gating behavior.

Also applies to: 272-299, 302-313

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/prowgen/prowgen.go` around lines 227 - 243, The code clears slackConfig
by setting it to nil to suppress Slack for periodic-derived presubmits, but nil
is interpreted later by slackReporterConfig(...) and causes an undesired
fallback to the legacy .config.prowgen; instead, explicitly pass a non-nil
SlackReporterConfig that indicates "do not report presubmits." Change the branch
that currently does "slackConfig = nil" to assign a new
cioperatorapi.SlackReporterConfig value with ReportPresubmit set to false (and
preserve any other needed fields if present) so generatePresubmitForTest(...) /
slackReporterConfig(...) receives an explicit config and will not fall back to
the legacy reporter; update the same pattern for the other occurrences around
the handlePresubmit flow (the slackConfig variable, the generatePresubmitForTest
call, and any paths that call slackReporterConfig(...)).
🧹 Nitpick comments (1)
test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml (1)

43-61: ⚡ Quick win

Add a fixture for the legacy fallback migration path.

This input proves inline reporter_config behavior, but it does not cover a periodic+presubmit test that gets Slack settings only from .config.prowgen. Without that case, the report_presubmit gate can regress while the inline path still passes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml`
around lines 43 - 61, Add a fixture that exercises the legacy fallback
(periodic+presubmit) path by adding a job entry that has cron: '@daily' and
presubmit: true but does NOT include an inline reporter_config so the Slack
settings must be read from .config.prowgen; e.g., add a new job block (name it
verify-legacy or similar) with as: verify-legacy, commands: make verify,
container.from: src, cron: '@daily', presubmit: true and omit reporter_config
and report_presubmit keys so the code path that falls back to .config.prowgen is
covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/prowgen/prowgen.go`:
- Around line 227-243: The code clears slackConfig by setting it to nil to
suppress Slack for periodic-derived presubmits, but nil is interpreted later by
slackReporterConfig(...) and causes an undesired fallback to the legacy
.config.prowgen; instead, explicitly pass a non-nil SlackReporterConfig that
indicates "do not report presubmits." Change the branch that currently does
"slackConfig = nil" to assign a new cioperatorapi.SlackReporterConfig value with
ReportPresubmit set to false (and preserve any other needed fields if present)
so generatePresubmitForTest(...) / slackReporterConfig(...) receives an explicit
config and will not fall back to the legacy reporter; update the same pattern
for the other occurrences around the handlePresubmit flow (the slackConfig
variable, the generatePresubmitForTest call, and any paths that call
slackReporterConfig(...)).

---

Nitpick comments:
In
`@test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml`:
- Around line 43-61: Add a fixture that exercises the legacy fallback
(periodic+presubmit) path by adding a job entry that has cron: '@daily' and
presubmit: true but does NOT include an inline reporter_config so the Slack
settings must be read from .config.prowgen; e.g., add a new job block (name it
verify-legacy or similar) with as: verify-legacy, commands: make verify,
container.from: src, cron: '@daily', presubmit: true and omit reporter_config
and report_presubmit keys so the code path that falls back to .config.prowgen is
covered.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: f2793994-991e-4fbd-a4da-c188c5450948

📥 Commits

Reviewing files that changed from the base of the PR and between 978d30b and 70184f0.

⛔ Files ignored due to path filters (2)
  • pkg/api/zz_generated.deepcopy.go is excluded by !**/zz_generated*
  • pkg/webreg/zz_generated.ci_operator_reference.go is excluded by !**/zz_generated*
📒 Files selected for processing (7)
  • pkg/api/types.go
  • pkg/prowgen/prowgen.go
  • pkg/validation/test.go
  • test/integration/ci-operator-prowgen/input/config/slack-report-inline/duper/slack-report-inline-duper-master.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-periodics.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-postsubmits.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-presubmits.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-presubmits.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-periodics.yaml
  • test/integration/ci-operator-prowgen/output/jobs/slack-report-inline/duper/slack-report-inline-duper-master-postsubmits.yaml

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@Prucek
Copy link
Copy Markdown
Member Author

Prucek commented Apr 30, 2026

/override ci/prow/images
/override ci/prow/e2e
We don't have to run them, they are going to fail anyway -_-
/skip

@Prucek
Copy link
Copy Markdown
Member Author

Prucek commented Apr 30, 2026

/label ready-for-human-review

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Apr 30, 2026
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 30, 2026

@Prucek: Overrode contexts on behalf of Prucek: ci/prow/e2e, ci/prow/images

Details

In response to this:

/override ci/prow/images
/override ci/prow/e2e
We don't have to run them, they are going to fail anyway -_-
/skip

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.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 30, 2026

@Prucek: The following test 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/breaking-changes 70184f0 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.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

3 similar comments
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant