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 logs with explicit RUNNING/SUCCESS/FAILED/NOT_MET/SKIPPED statuses and a distinct Post Actions phase.
    • Consolidated many per-item lines into concise phase-level summaries.
    • Reduced default verbosity for API, discovery, precondition, resource, 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
@coderabbitai
Copy link

coderabbitai bot commented Dec 31, 2025

Walkthrough

Changes convert executor logging to a phase-oriented model: phases (ParamExtraction, Preconditions, Resources, Post Actions, Finalization) now emit phase-qualified RUNNING/SUCCESS/FAILED/NOT_MET messages and concise phase-level summaries. Per-item index-based logs were replaced with name-based logs or consolidated phase summaries. Resource execution now computes an explicit operation (Skip/Create/Update/Recreate) with an OperationReason and centralizes operation decision and execution. Precondition and post-action code switched many Info logs to Debug and adjusted error formatting to include error=. 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

  • ciaranRoche
  • 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 directly describes the primary change: formalizing executor logging for debugging and tracking. It accurately reflects the widespread log message restructuring across multiple executor files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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

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 (3)
internal/executor/executor.go (2)

110-110: Redundant error= in wrapped error message.

The format "precondition evaluation failed: error=%w" will produce messages like:
"precondition evaluation failed: error=<actual error>".

This is inconsistent with other wrapped errors in the file (lines 138, 162) which don't include error= in the format string. The error= prefix should only appear in log statements, not in error wrapping.

🔎 Suggested fix
-		precondErr := fmt.Errorf("precondition evaluation failed: error=%w", precondOutcome.Error)
+		precondErr := fmt.Errorf("precondition evaluation failed: %w", precondOutcome.Error)

238-258: Inconsistent error= placement in error wrapping.

The error= prefix in fmt.Errorf calls (lines 238, 244, 251, 257) creates error messages like:
"failed to marshal map data: error=<actual error>"

This is inconsistent with Go error wrapping conventions where %w naturally chains errors. The error= prefix should be reserved for log output, not embedded in error messages.

However, if this is intentional per logging spec to ensure error= appears in all error contexts, please confirm this is the desired behavior.

🔎 Suggested fix (if not intentional)
-		return nil, nil, fmt.Errorf("failed to marshal map data: error=%w", err)
+		return nil, nil, fmt.Errorf("failed to marshal map data: %w", err)
-		return nil, nil, fmt.Errorf("failed to marshal data: error=%w", err)
+		return nil, nil, fmt.Errorf("failed to marshal data: %w", err)
-		return nil, nil, fmt.Errorf("failed to unmarshal to EventData: error=%w", err)
+		return nil, nil, fmt.Errorf("failed to unmarshal to EventData: %w", err)
-		return nil, nil, fmt.Errorf("failed to unmarshal to map: error=%w", err)
+		return nil, nil, fmt.Errorf("failed to unmarshal to map: %w", err)
internal/executor/resource_executor.go (1)

143-143: Minor: Trailing whitespace after switch block.

Line 143 appears to have trailing whitespace. Consider removing for consistency.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

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

📒 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 (1)
  • internal/executor/types.go
🧰 Additional context used
🧠 Learnings (2)
📓 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.
📚 Learning: 2025-12-04T14:06:51.656Z
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.

Applied to files:

  • internal/executor/post_action_executor.go
🧬 Code graph analysis (3)
internal/executor/resource_executor.go (2)
internal/executor/types.go (6)
  • OperationRecreate (155-155)
  • OperationUpdate (153-153)
  • OperationCreate (151-151)
  • OperationSkip (157-157)
  • NewExecutorError (375-382)
  • PhaseResources (25-25)
internal/config_loader/types.go (1)
  • Resource (229-234)
internal/executor/executor.go (2)
internal/config_loader/types.go (1)
  • AdapterConfig (59-64)
internal/executor/types.go (4)
  • StatusFailed (37-37)
  • PhaseResources (25-25)
  • PhasePostActions (27-27)
  • EventData (48-54)
internal/executor/post_action_executor.go (1)
internal/config_loader/types.go (1)
  • APICall (161-169)
🔇 Additional comments (18)
internal/executor/post_action_executor.go (2)

55-72: LGTM! Logging changes align with phase-based pattern.

The switch from index-based to name-based logging (PostAction[%s]) improves readability and debugging. The error= and status= prefixes are consistent with the logging specification as discussed in past reviews.


218-222: LGTM! API call logging appropriately moved to Debug level.

Downgrading API call start/finish logs from Infof to Debugf reduces log noise while still providing visibility when debug logging is enabled.

internal/executor/executor.go (5)

58-64: LGTM! Parse error handling with phase context.

The error is properly logged with error= prefix and the phase is correctly set to PhaseParamExtraction.


91-99: LGTM! Phase RUNNING log for parameter extraction.

Clear phase start indication that aids in debugging and tracking execution flow.


103-127: LGTM! Preconditions phase logging with detailed outcomes.

The logging distinguishes between:

  • FAILED (execution error)
  • SUCCESS - NOT_MET (business condition not satisfied)
  • SUCCESS - MET (all conditions passed)

This provides good visibility into precondition evaluation outcomes.


131-148: LGTM! Resources phase logging.

Clear phase transitions with configured count and outcome status (SUCCESS/SKIPPED/FAILED).


151-167: LGTM! Post actions phase logging.

Properly handles the case where Post config may be nil when determining action count. Phase transitions are consistent with other phases.

internal/executor/resource_executor.go (5)

42-52: LGTM! Simplified iteration pattern.

The switch from index-based to range-based iteration is cleaner and aligns with the broader logging refactor.


76-76: LGTM! Manifest built log provides useful context.

The log includes resource name, kind, name, and namespace - all essential for debugging.


94-98: LGTM! Discovery outcome logging.

Debug-level logs for discovery results are appropriate - they provide detail when needed without cluttering normal output.


101-142: LGTM! Centralized operation decision logic.

The refactored code clearly:

  1. Determines the operation (Skip/Create/Update/Recreate) with reasons
  2. Logs the decision before execution
  3. Executes via a switch statement

This is easier to follow than inline decision/execution and improves debuggability.


153-159: LGTM! Consistent success/failure logging.

Error and success logs follow the established pattern with operation, reason, kind, and name context.

internal/executor/precondition_executor.go (6)

35-61: LGTM! Precondition evaluation logging.

The logging clearly distinguishes between:

  • FAILED - execution/API errors
  • NOT_MET - business condition not satisfied with details
  • MET - condition passed

The formatConditionDetails helper provides useful context for NOT_MET cases.


86-86: LGTM! API call logging downgraded to Debug.

Consistent with the same change in post_action_executor.go.


126-153: LGTM! Field capture logging at Debug level.

Appropriate verbosity for field capture details while maintaining visibility when needed.


170-191: LGTM! Structured condition evaluation logging.

The differentiation between matched (Debug) and not-matched (Info) conditions is appropriate - only non-matching conditions are surfaced at Info level for visibility.


199-218: LGTM! CEL expression evaluation logging.

Debug-level logging for CEL expression and results is appropriate. The auto-match case for no conditions is also correctly logged at Debug level.


236-256: LGTM! Well-implemented helper function.

formatConditionDetails handles:

  • CEL errors
  • Unmatched structured conditions with field/operator/expected/actual values
  • Empty case with fallback message

Good defensive coding with the "no specific details available" fallback.

@86254860
Copy link

86254860 commented Jan 7, 2026

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Jan 7, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 86254860

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 label Jan 7, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit a5be140 into openshift-hyperfleet:main Jan 7, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants