Skip to content

Conversation

@xueli181114
Copy link
Contributor

@xueli181114 xueli181114 commented Dec 31, 2025

Summary by CodeRabbit

  • New Features

    • Exposed operation-reason details for resource execution results to clarify why actions ran.
  • Chores

    • Introduced phase-based execution logging with explicit RUNNING/SUCCESS/FAILED/NOT_MET/SKIPPED indicators, including a distinct Post Actions phase.
    • Consolidated per-item logs into concise phase-level summaries.
    • Reduced default log verbosity for API, discovery, precondition and post-action steps; switched to name-based action references.

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci openshift-ci bot requested a review from ciaranRoche December 31, 2025 10:51
@openshift-ci
Copy link

openshift-ci bot commented Dec 31, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

coderabbitai bot commented Dec 31, 2025

Walkthrough

The diff refactors executor logging into a phase-oriented model: phases (Parameter Extraction, Preconditions, Resources, Post Actions, Finalization) now emit phase-qualified RUNNING/FAILED/NOT_MET/SUCCESS messages and phase-level summaries. Per-item index-based logs were replaced by name-based logs or consolidated phase summaries. Resource execution adds generation-based decision logic (Create/Update/Recreate/Skip) and records an OperationReason on ResourceResult. API/discovery logs were lowered from Info to Debug in several places. No exported function or type signatures were changed.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

lgtm, approved

Suggested reviewers

  • tirthct

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: formalizing executor logging for improved debugging and tracking, which aligns with the substantive changes across multiple executor files to restructure and standardize log messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

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

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: 0

🧹 Nitpick comments (1)
internal/executor/resource_executor.go (1)

153-159: Consider splitting long log lines for readability.

The detailed logging is excellent for debugging, but the lines exceed typical length guidelines. Consider formatting the log arguments across multiple lines for better maintainability.

🔎 Optional formatting improvement
-	re.log.Errorf(ctx, "Resource[%s] processed: FAILED - operation=%s reason=%s kind=%s name=%s error=%v", 
-		resource.Name, result.Operation, result.OperationReason, gvk.Kind, manifest.GetName(), err)
+	re.log.Errorf(ctx, 
+		"Resource[%s] processed: FAILED - operation=%s reason=%s kind=%s name=%s error=%v",
+		resource.Name, result.Operation, result.OperationReason, gvk.Kind, manifest.GetName(), err)
-	re.log.Infof(ctx, "Resource[%s] processed: SUCCESS - operation=%s reason=%s kind=%s name=%s", 
-		resource.Name, result.Operation, result.OperationReason, gvk.Kind, manifest.GetName())
+	re.log.Infof(ctx,
+		"Resource[%s] processed: SUCCESS - operation=%s reason=%s kind=%s name=%s",
+		resource.Name, result.Operation, result.OperationReason, gvk.Kind, manifest.GetName())
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8627b2a and 79bf801.

📒 Files selected for processing (5)
  • internal/executor/executor.go
  • internal/executor/post_action_executor.go
  • internal/executor/precondition_executor.go
  • internal/executor/resource_executor.go
  • internal/executor/types.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/executor/post_action_executor.go
  • internal/executor/types.go
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: xueli181114
Repo: openshift-hyperfleet/hyperfleet-adapter PR: 13
File: internal/executor/post_action_executor.go:198-205
Timestamp: 2025-12-04T14:06:51.656Z
Learning: Logger refactor is tracked in HYPERFLEET-304 for the hyperfleet-adapter repository, which will address how CEL evaluation failures and similar errors are handled and logged.
🧬 Code graph analysis (1)
internal/executor/executor.go (1)
internal/executor/types.go (3)
  • PhaseResources (25-25)
  • PhasePostActions (27-27)
  • StatusFailed (37-37)
🔇 Additional comments (8)
internal/executor/executor.go (2)

91-127: LGTM! Phase-oriented logging enhances observability.

The phase-qualified logs (RUNNING, SUCCESS, FAILED, NOT_MET) provide clear execution flow and debugging context. The distinction between phase execution success and business outcomes (MET vs. NOT_MET) is well-handled.


131-167: LGTM! Resource and post-action phase logging is consistent.

The phase-driven logging pattern is uniformly applied to resource and post-action phases, including proper handling of skipped resources and comprehensive error context.

internal/executor/resource_executor.go (3)

6-6: LGTM! Name-based iteration and logging improve clarity.

The shift from index-based to name-based iteration and logging makes debugging easier by using meaningful resource identifiers throughout the execution flow.

Also applies to: 42-42, 76-76


95-98: LGTM! Appropriate log level adjustment.

Moving discovery logs to Debug level reduces noise while maintaining visibility when detailed troubleshooting is needed.


101-143: LGTM! Operation decision logic is well-structured.

The refactored decision logic cleanly separates operation determination from execution. The generation-based change detection with OperationReason provides clear audit trails for debugging. The switch statement improves maintainability and makes the execution flow explicit.

internal/executor/precondition_executor.go (3)

35-61: LGTM! Name-based precondition logging improves traceability.

The refactored iteration and logging using precondition names rather than indices makes debugging clearer. The formatConditionDetails helper provides structured failure reasons that enhance observability.


86-86: LGTM! Appropriate log level adjustments for API call details.

Moving API call implementation details to Debug level reduces noise in standard operations while keeping detailed traces available for troubleshooting.

Also applies to: 126-126, 153-153


171-171: LGTM! Well-balanced log level adjustments for conditions.

The log level changes appropriately distinguish between implementation details (Debug) and business outcomes (Info). Keeping NOT_MET conditions at Info level ensures visibility for operational issues while reducing noise from successful evaluations.

Also applies to: 187-187, 189-189, 201-201, 211-211, 217-217

result.Errors[result.CurrentPhase] = precondErr
execCtx.SetError("PreconditionFailed", precondOutcome.Error.Error())
e.log.Errorf(ctx, "Precondition execution failed: %v", precondOutcome.Error)
e.log.Errorf(ctx, "Phase %s: FAILED - %v", result.CurrentPhase, precondOutcome.Error)
Copy link

Choose a reason for hiding this comment

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

Do you mean it should add error= here? Should we keep consistent in one PR?

result.Errors[result.CurrentPhase] = resErr
execCtx.SetError("ResourceFailed", err.Error())
e.log.Errorf(ctx, "Resource execution FAILED: %v", err)
e.log.Errorf(ctx, "Phase %s: FAILED - %v", result.CurrentPhase, err)
Copy link

Choose a reason for hiding this comment

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

As above.

postErr := fmt.Errorf("post action execution failed: %w", err)
result.Errors[result.CurrentPhase] = postErr
e.log.Errorf(ctx, "Post action execution FAILED: %v", err)
e.log.Errorf(ctx, "Phase %s: FAILED - %v", result.CurrentPhase, err)
Copy link

Choose a reason for hiding this comment

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

As above.

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