Skip to content

NOJIRA: Dummy PR automatic addressing code review#369

Open
neha037 wants to merge 3 commits into
openshift:masterfrom
neha037:dummy-for-review-comments
Open

NOJIRA: Dummy PR automatic addressing code review#369
neha037 wants to merge 3 commits into
openshift:masterfrom
neha037:dummy-for-review-comments

Conversation

@neha037

@neha037 neha037 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for must-gather image stream references to prevent failures when the referenced image stream name or tag is missing.
    • Enhanced job reconciliation logs by reporting a human-readable job age while checking job status.
    • Updated cleanup messaging to report how many pods were deleted during must-gather cleanup.
  • New Features
    • Added an additional progress log indicating the configured must-gather timeout, including its duration value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot requested review from TrilokGeer and rbhilare July 2, 2026 05:21
@openshift-ci

openshift-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: neha037
Once this PR has been reviewed and has the lgtm label, please assign swghosh 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

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ff37c8f4-3c37-4c57-9a5c-a3b569ea1c7c

📥 Commits

Reviewing files that changed from the base of the PR and between 1c11252 and fd50b5e.

📒 Files selected for processing (1)
  • controllers/mustgather/mustgather_controller.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • controllers/mustgather/mustgather_controller.go

Walkthrough

Adds must-gather controller logging for job age, cleanup counts, and configured timeouts, and validates image stream references before tag lookup.

Changes

Must-gather controller updates

Layer / File(s) Summary
Template timeout logging
controllers/mustgather/template.go
Logs the configured MustGatherTimeout value when the timeout is set.
Job age logging
controllers/mustgather/mustgather_controller.go
Computes a human-readable job age during reconciliation and includes it in the job-status check log.
ImageStreamRef validation
controllers/mustgather/mustgather_controller.go
Rejects empty image stream name or tag values before tag lookup.
Cleanup summary logging
controllers/mustgather/mustgather_controller.go
Logs cleanup completion with the job name and deleted pod count.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 11

❌ Failed checks (11 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is generic and does not clearly describe the must-gather controller changes in this PR. Rename the PR to summarize the main code change, such as must-gather controller logging and validation improvements.
Stable And Deterministic Test Names ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Test Structure And Quality ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Microshift Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Single Node Openshift (Sno) Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Topology-Aware Scheduling Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ote Binary Stdout Contract ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ipv6 And Disconnected Network Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Weak-Crypto ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Container-Privileges ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Sensitive-Data-In-Logs ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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

Comment thread controllers/mustgather/template.go Outdated
Comment on lines +430 to +445

// formatDuration converts a duration to a human-readable string like "2h 30m 15s".
func formatDuration(d time.Duration) string {
totalSeconds := int(d.Seconds())
hours := totalSeconds / 3600
minutes := (totalSeconds % 3600) / 60
seconds := totalSeconds % 60

if hours > 0 {
return fmt.Sprintf("%dh %dm %ds", hours, minutes, seconds)
}
if minutes > 0 {
return fmt.Sprintf("%dm %ds", minutes, seconds)
}
return fmt.Sprintf("%ds", seconds)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just use duration.String()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Done. Replaced custom formatDuration function with Go's built-in duration.String() method in controllers/mustgather/template.go:117.


AI-assisted response via Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (5)
controllers/mustgather/mustgather_controller.go (4)

692-701: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop unnecessary fmt.Sprintf calls with no format arguments.

goerror.New(fmt.Sprintf("imageStreamRef.name must not be empty")) has no format directives; fmt.Sprintf is redundant here.

♻️ Proposed fix
 func validateImageStreamRef(ref *mustgatherv1alpha1.ImageStreamTagRef) error {
 	if len(ref.Name) == 0 {
-		return goerror.New(fmt.Sprintf("imageStreamRef.name must not be empty"))
+		return goerror.New("imageStreamRef.name must not be empty")
 	}
 	if len(ref.Tag) == 0 {
-		return goerror.New(fmt.Sprintf("imageStreamRef.tag must not be empty"))
+		return goerror.New("imageStreamRef.tag must not be empty")
 	}
 	return nil
 }
🤖 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 `@controllers/mustgather/mustgather_controller.go` around lines 692 - 701, The
validateImageStreamRef helper is wrapping static error strings with unnecessary
fmt.Sprintf calls. In validateImageStreamRef, replace the
goerror.New(fmt.Sprintf(...)) calls for the Name and Tag checks with direct
string-based error construction, since there are no format arguments; keep the
same validation behavior while simplifying the error creation.

688-688: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use time.Since instead of time.Now().Sub(...).

time.Since(t) is the idiomatic shorthand for time.Now().Sub(t).

♻️ Proposed fix
-	age := time.Now().Sub(job.CreationTimestamp.Time)
+	age := time.Since(job.CreationTimestamp.Time)
🤖 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 `@controllers/mustgather/mustgather_controller.go` at line 688, Replace the age
calculation in the mustgather controller with the idiomatic time.Since form
instead of calling time.Now().Sub on job.CreationTimestamp.Time. Update the code
in the logic that computes job age to use time.Since with the same timestamp
value so the behavior stays identical while matching Go conventions.

703-712: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer structured key/value logging over pre-formatted messages.

Elsewhere in this file, reqLogger.Info uses structured key-value pairs (e.g. reqLogger.Info("failed to get job", "job", instance.Name)), whereas logCleanupSummary builds the whole message via fmt.Sprintf. This is inconsistent with the surrounding logging style and loses structured-log queryability (e.g., filtering by podCount).

♻️ Proposed fix
 func logCleanupSummary(reqLogger logr.Logger, jobName string, podCount int) {
-	if podCount == 0 {
-		msg := fmt.Sprintf("cleanup complete for job %s: no pods were deleted", jobName)
-		reqLogger.Info(msg)
-	} else {
-		msg := fmt.Sprintf("cleanup complete for job %s: deleted %d pod(s)", jobName, podCount)
-		reqLogger.Info(msg)
-	}
+	reqLogger.Info("cleanup complete", "job", jobName, "podsDeleted", podCount)
 }
🤖 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 `@controllers/mustgather/mustgather_controller.go` around lines 703 - 712,
logCleanupSummary currently formats the entire cleanup message with fmt.Sprintf,
which is inconsistent with the structured logging used elsewhere in
mustgather_controller.go. Update logCleanupSummary to call reqLogger.Info with a
constant message and key/value pairs for jobName and podCount (and any needed
status field for the zero-pod case) so the cleanup summary remains queryable and
consistent with the surrounding logging style.

687-690: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider reusing formatDuration instead of Duration.String().

getJobAge and template.go's new formatDuration both format a time.Duration for logging but produce inconsistent output styles (age.String() yields Go's default "2h3m4.567s" format vs. formatDuration's "2h 30m 15s"). Consolidating avoids duplicated duration-formatting logic and keeps log output consistent across the reconciler.

♻️ Proposed consolidation
 func getJobAge(job *batchv1.Job) string {
-	age := time.Now().Sub(job.CreationTimestamp.Time)
-	return age.String()
+	return formatDuration(time.Since(job.CreationTimestamp.Time))
 }
🤖 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 `@controllers/mustgather/mustgather_controller.go` around lines 687 - 690, The
getJobAge helper is formatting a duration directly with Duration.String(), which
duplicates the duration formatting logic already centralized in formatDuration
and produces inconsistent log output. Update getJobAge to reuse formatDuration
for the computed age so the reconciler’s job-age logging matches the style used
in template.go and keeps duration formatting in one place.
controllers/mustgather/template.go (1)

430-445: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate duration-formatting logic vs. getJobAge in mustgather_controller.go.

Same concern raised in mustgather_controller.gogetJobAge uses Duration.String() while this uses a custom "Xh Ym Zs" format, producing inconsistent duration representations across the same package's logs. Consider having getJobAge call this helper (or vice versa) for a single source of truth.

🤖 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 `@controllers/mustgather/template.go` around lines 430 - 445, The duration
formatting logic is duplicated and inconsistent between formatDuration and
getJobAge, so unify them to a single source of truth. Update getJobAge in
mustgather_controller.go to use formatDuration (or have formatDuration delegate
to the same logic) so all duration strings in this package share the same
human-readable format. Keep the change centered around the existing getJobAge
and formatDuration symbols so the representation stays consistent across logs.
🤖 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.

Nitpick comments:
In `@controllers/mustgather/mustgather_controller.go`:
- Around line 692-701: The validateImageStreamRef helper is wrapping static
error strings with unnecessary fmt.Sprintf calls. In validateImageStreamRef,
replace the goerror.New(fmt.Sprintf(...)) calls for the Name and Tag checks with
direct string-based error construction, since there are no format arguments;
keep the same validation behavior while simplifying the error creation.
- Line 688: Replace the age calculation in the mustgather controller with the
idiomatic time.Since form instead of calling time.Now().Sub on
job.CreationTimestamp.Time. Update the code in the logic that computes job age
to use time.Since with the same timestamp value so the behavior stays identical
while matching Go conventions.
- Around line 703-712: logCleanupSummary currently formats the entire cleanup
message with fmt.Sprintf, which is inconsistent with the structured logging used
elsewhere in mustgather_controller.go. Update logCleanupSummary to call
reqLogger.Info with a constant message and key/value pairs for jobName and
podCount (and any needed status field for the zero-pod case) so the cleanup
summary remains queryable and consistent with the surrounding logging style.
- Around line 687-690: The getJobAge helper is formatting a duration directly
with Duration.String(), which duplicates the duration formatting logic already
centralized in formatDuration and produces inconsistent log output. Update
getJobAge to reuse formatDuration for the computed age so the reconciler’s
job-age logging matches the style used in template.go and keeps duration
formatting in one place.

In `@controllers/mustgather/template.go`:
- Around line 430-445: The duration formatting logic is duplicated and
inconsistent between formatDuration and getJobAge, so unify them to a single
source of truth. Update getJobAge in mustgather_controller.go to use
formatDuration (or have formatDuration delegate to the same logic) so all
duration strings in this package share the same human-readable format. Keep the
change centered around the existing getJobAge and formatDuration symbols so the
representation stays consistent across logs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 58dddf2e-0ad1-4311-b39c-4333d4395062

📥 Commits

Reviewing files that changed from the base of the PR and between 6860bae and bb4b331.

📒 Files selected for processing (2)
  • controllers/mustgather/mustgather_controller.go
  • controllers/mustgather/template.go

@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.97%. Comparing base (e65f61a) to head (fd50b5e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
controllers/mustgather/mustgather_controller.go 62.50% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #369      +/-   ##
==========================================
- Coverage   82.32%   81.97%   -0.35%     
==========================================
  Files           8        8              
  Lines         905      921      +16     
==========================================
+ Hits          745      755      +10     
- Misses        148      151       +3     
- Partials       12       15       +3     
Files with missing lines Coverage Δ
controllers/mustgather/template.go 100.00% <100.00%> (ø)
controllers/mustgather/mustgather_controller.go 92.60% <62.50%> (-1.40%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…pe-pr-agent

- Use time.Since instead of time.Now().Sub for idiomatic duration calculation
- Remove unnecessary fmt.Sprintf calls in validateImageStreamRef
- Convert logCleanupSummary to structured logging with key/value pairs
@openshift-app-platform-shift

Copy link
Copy Markdown

Done. Applied the following code quality improvements in commit fd50b5e:

  1. time.Since: Changed time.Now().Sub() to time.Since() in getJobAge (line 688)
  2. Removed unnecessary fmt.Sprintf: Simplified error creation in validateImageStreamRef (lines 692-701)
  3. Structured logging: Converted logCleanupSummary to use key/value pairs instead of pre-formatted messages (lines 703-712)

Note on formatDuration: The suggestions about unifying duration formatting (lines 687-690 and template.go 430-445) were already addressed in commit 1c11252, which removed the custom formatDuration function in favor of using .String() consistently throughout the codebase.


AI-assisted response via Claude Code

@neha037

neha037 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@neha037: 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/validate-boilerplate fd50b5e link false /test validate-boilerplate

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