Skip to content

SDCICD-1766: Add must-gather link to krknai report if enabled#3142

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
minlei98:SDCICD-1766
Mar 11, 2026
Merged

SDCICD-1766: Add must-gather link to krknai report if enabled#3142
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
minlei98:SDCICD-1766

Conversation

@minlei98
Copy link
Contributor

@minlei98 minlei98 commented Mar 6, 2026

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

  • Krkn-AI command (--skip-must-gather, default true; PostProcessCluster before Report)
  • Orchestrator (PostProcessCluster, no Ginkgo, 30-min timeout)
  • Cluster package (RunMustGatherToDir)
  • Config (SkipMustGather)
  • HTML report (must-gather link, relative path, 1.5em font)

Summary by CodeRabbit

  • New Features
    • Added --skip-must-gather flag to optionally bypass must-gather collection after chaos tests (enabled by default).
    • Integrated must-gather artifacts into HTML reports with clickable links for easy access.
    • Implemented must-gather execution in the post-test workflow with proper error handling.

@openshift-ci-robot
Copy link

There are test jobs defined for this repository which are not configured to run automatically. Comment /test ? to see a list of all defined jobs. Review these jobs and use /test <job> to manually trigger jobs most likely to be impacted by the proposed changes.Comment /pipeline required to trigger all required & necessary jobs.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 6, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 6, 2026

@minlei98: This pull request references SDCICD-1766 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

  • cmd/osde2e/krknai/cmd.go
    Add --skip-must-gather (default true) and bind to config.SkipMustGather.

  • pkg/krknai/krknai.go
    In PostProcessCluster: if not dry-run and not skip-must-gather, create helper, set phase to MustGatherPhase, call cluster.RunMustGather(ctx, h), then clear phase.
    Reuse existing cluster.RunMustGather and helper.NewOutsideGinkgo() (same pattern as e2e).

  • pkg/krknai/analysisengine/engine.go
    Add mustGatherRelativePath(artifactsDir) to detect a must-gather directory under artifacts and return a relative path or "".
    When rendering HTML, pass that path into the report template so the link is shown only when must-gather exists.

  • pkg/krknai/analysisengine/prompts/report.html
    Add optional “Cluster must-gather” link paragraph when MustGatherPath is set.

  • pkg/krknai/analysisengine/engine_test.go
    Add TestRun_HTMLReportFormat_WithMustGatherLink to assert the HTML contains the link when a must-gather dir exists under artifacts.

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 openshift-eng/jira-lifecycle-plugin repository.

@ritmun
Copy link
Contributor

ritmun commented Mar 6, 2026

@CodeRabbit review

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 2119f1c2-8eab-48ef-92c2-853828ef4460

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

The changes add optional must-gather collection after chaos test execution, controlled by a new --skip-must-gather CLI flag. The analysis engine generates HTML reports with links to must-gather artifacts when available, and a new test validates this functionality.

Changes

Cohort / File(s) Summary
CLI Flag Configuration
cmd/osde2e/krknai/cmd.go
Added --skip-must-gather persistent flag with default value true and bound it to configuration via viper.
Must-Gather Phase Implementation
pkg/krknai/krknai.go
Introduced MustGatherPhase constant and PostProcessCluster function to execute cluster must-gather when not in dry-run or skip mode, with proper phase management and error handling.
Analysis Engine Enhancement
pkg/krknai/analysisengine/engine.go
Added mustGatherRelativePath function to locate must-gather artifacts and modified markdownToHTML signature to accept must-gather path parameter for template payload injection.
HTML Template Updates
pkg/krknai/analysisengine/prompts/report.html
Added conditional must-gather link rendering in HTML template with styling when MustGatherPath is populated.
Test Coverage
pkg/krknai/analysisengine/engine_test.go
Added TestRun_HTMLReportFormat_WithMustGatherLink to verify must-gather link presence and formatting in HTML output.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant CLI as CLI Handler
    participant Cluster as Cluster
    participant Engine as Analysis Engine
    participant Template as HTML Template

    User->>CLI: Run test with --skip-must-gather flag
    CLI->>Cluster: Execute chaos test
    Cluster->>Cluster: Test completes
    alt skip-must-gather not set
        Cluster->>Cluster: PostProcessCluster: Phase=MustGatherPhase
        Cluster->>Cluster: RunMustGather()
        Cluster->>Cluster: Phase restored
    end
    Cluster->>Engine: Invoke analysis
    Engine->>Engine: Compute mustGatherRelativePath
    Engine->>Template: Render HTML with MustGatherPath
    Template->>Template: Generate report with must-gather link
    Template-->>User: HTML report
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding must-gather link functionality to krknai reports with conditional enabling.
Stable And Deterministic Test Names ✅ Passed Pull request introduces only standard Go unit tests with stable, deterministic names following Go conventions. No Ginkgo test declarations present.
Test Structure And Quality ✅ Passed Test adheres to quality requirements: single responsibility, idiomatic cleanup via t.TempDir(), assertion style consistent with codebase, mirrors TestRun_HTMLReportFormat pattern.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 6, 2026

@minlei98: This pull request references SDCICD-1766 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

  • cmd/osde2e/krknai/cmd.go
    Add --skip-must-gather (default true) and bind to config.SkipMustGather.

  • pkg/krknai/krknai.go
    In PostProcessCluster: if not dry-run and not skip-must-gather, create helper, set phase to MustGatherPhase, call cluster.RunMustGather(ctx, h), then clear phase.
    Reuse existing cluster.RunMustGather and helper.NewOutsideGinkgo() (same pattern as e2e).

  • pkg/krknai/analysisengine/engine.go
    Add mustGatherRelativePath(artifactsDir) to detect a must-gather directory under artifacts and return a relative path or "".
    When rendering HTML, pass that path into the report template so the link is shown only when must-gather exists.

  • pkg/krknai/analysisengine/prompts/report.html
    Add optional “Cluster must-gather” link paragraph when MustGatherPath is set.

  • pkg/krknai/analysisengine/engine_test.go
    Add TestRun_HTMLReportFormat_WithMustGatherLink to assert the HTML contains the link when a must-gather dir exists under artifacts.

Summary by CodeRabbit

  • New Features
  • Added --skip-must-gather flag to optionally bypass must-gather collection after chaos tests (enabled by default).
  • Integrated must-gather artifacts into HTML reports with clickable links for easy access.
  • Implemented must-gather execution in the post-test workflow with proper error handling.

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 openshift-eng/jira-lifecycle-plugin repository.

@ritmun
Copy link
Contributor

ritmun commented Mar 6, 2026

/pipeline required

@openshift-ci-robot
Copy link

Scheduling required tests:
/test hypershift-pr-check

Copy link

@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: 2

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

Inline comments:
In `@cmd/osde2e/krknai/cmd.go`:
- Around line 82-93: The skip-must-gather flag binding in cmd.go causes
artifacts to be collected after reporting because
pkg/krknai/analysisengine/engine.go resolves must-gather during orch.Report(ctx)
but the command still calls orch.PostProcessCluster(ctx) afterward; change the
command flow so that when args.skipMustGather is false you perform the
must-gather/PostProcessCluster step before calling orch.Report(ctx) (or refactor
Report to invoke the must-gather resolution early), updating the invocation
order around orch.Report(ctx) and orch.PostProcessCluster(ctx) to ensure
artifacts are collected prior to report generation and keeping the flag binding
(config.SkipMustGather) intact.

In `@pkg/krknai/krknai.go`:
- Around line 372-374: The deferred viper.Set currently clears the global
config.Phase which can clobber an existing phase; modify the code around the
must-gather block (where viper.Set(config.Phase, MustGatherPhase) is called) to
first read and store the current phase (e.g., prev :=
viper.GetString(config.Phase)), then set MustGatherPhase, and in the defer
restore the saved value (defer viper.Set(config.Phase, prev)) so the original
phase is reinstated instead of being emptied; update any surrounding comments to
reflect restoring previous state.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 5abea0a8-c6cf-4575-81e5-978a86f65749

📥 Commits

Reviewing files that changed from the base of the PR and between 37d4993 and 47e8714.

📒 Files selected for processing (5)
  • cmd/osde2e/krknai/cmd.go
  • pkg/krknai/analysisengine/engine.go
  • pkg/krknai/analysisengine/engine_test.go
  • pkg/krknai/analysisengine/prompts/report.html
  • pkg/krknai/krknai.go

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 7, 2026

@minlei98: This pull request references SDCICD-1766 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

Krkn-AI command (--skip-must-gather, default true; PostProcessCluster before Report)
Orchestrator (PostProcessCluster, no Ginkgo, 30-min timeout)
Cluster package (RunMustGatherToDir)
Config (SkipMustGather)
HTML report (must-gather link, relative path, 1.5em font)

Summary by CodeRabbit

  • New Features
  • Added --skip-must-gather flag to optionally bypass must-gather collection after chaos tests (enabled by default).
  • Integrated must-gather artifacts into HTML reports with clickable links for easy access.
  • Implemented must-gather execution in the post-test workflow with proper error handling.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 7, 2026

@minlei98: This pull request references SDCICD-1766 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

  • Krkn-AI command (--skip-must-gather, default true; PostProcessCluster before Report)
  • Orchestrator (PostProcessCluster, no Ginkgo, 30-min timeout)
  • Cluster package (RunMustGatherToDir)
  • Config (SkipMustGather)
  • HTML report (must-gather link, relative path, 1.5em font)

Summary by CodeRabbit

  • New Features
  • Added --skip-must-gather flag to optionally bypass must-gather collection after chaos tests (enabled by default).
  • Integrated must-gather artifacts into HTML reports with clickable links for easy access.
  • Implemented must-gather execution in the post-test workflow with proper error handling.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 7, 2026

@minlei98: This pull request references SDCICD-1766 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Enables cluster must-gather for the krkn-ai (KAIAAS) flow so users can inspect cluster state when reviewing chaos test results. Reuses the existing osde2e must-gather path and adds a link to it in the krkn-ai HTML report.

  • Krkn-AI command (--skip-must-gather, default true; PostProcessCluster before Report)
  • Orchestrator (PostProcessCluster, no Ginkgo, 30-min timeout)
  • Cluster package (RunMustGatherToDir)
  • Config (SkipMustGather)
  • HTML report (must-gather link, relative path, 1.5em font)

Summary by CodeRabbit

  • New Features
  • Added --skip-must-gather flag to optionally bypass must-gather collection after chaos tests (enabled by default).
  • Integrated must-gather artifacts into HTML reports with clickable links for easy access.
  • Implemented must-gather execution in the post-test workflow with proper error handling.

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 openshift-eng/jira-lifecycle-plugin repository.

@minlei98
Copy link
Contributor Author

minlei98 commented Mar 7, 2026

krknai-report-20260306-221424.html

@minlei98
Copy link
Contributor Author

minlei98 commented Mar 7, 2026

must_gather

@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 9, 2026
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 9, 2026
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 9, 2026
@varunraokadaparthi
Copy link
Contributor

/lgtm

@ritmun
Copy link
Contributor

ritmun commented Mar 9, 2026

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: minlei98, ritmun

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 Mar 9, 2026
@ritmun
Copy link
Contributor

ritmun commented Mar 9, 2026

/override hypershift-pr-check

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 9, 2026

@ritmun: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • hypershift-pr-check

Only the following failed contexts/checkruns were expected:

  • CodeRabbit
  • ci/prow/code-quality-checks
  • ci/prow/hypershift-pr-check
  • pull-ci-openshift-osde2e-main-code-quality-checks
  • pull-ci-openshift-osde2e-main-hypershift-pr-check
  • tide

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

Details

In response to this:

/override hypershift-pr-check

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.

@ritmun
Copy link
Contributor

ritmun commented Mar 9, 2026

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 9, 2026
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2026
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2026
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2026
@minlei98 minlei98 force-pushed the SDCICD-1766 branch 2 times, most recently from 121afa6 to b2a8493 Compare March 11, 2026 15:48
@ritmun
Copy link
Contributor

ritmun commented Mar 11, 2026

/override ci/prow/hypershift-pr-check

@ritmun
Copy link
Contributor

ritmun commented Mar 11, 2026

/hold cancel
/lgtm

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 11, 2026
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 11, 2026

@ritmun: Overrode contexts on behalf of ritmun: ci/prow/hypershift-pr-check

Details

In response to this:

/override ci/prow/hypershift-pr-check

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
Contributor

openshift-ci bot commented Mar 11, 2026

@minlei98: all tests passed!

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 openshift-merge-bot bot merged commit de7fc17 into openshift:main Mar 11, 2026
6 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants