Skip to content

OCPBUGS-85416: Enable actuators to set terminal failure on Exists and Update#1499

Open
mdbooth wants to merge 1 commit into
openshift:mainfrom
openshift-cloud-team:OCPBUGS-85416
Open

OCPBUGS-85416: Enable actuators to set terminal failure on Exists and Update#1499
mdbooth wants to merge 1 commit into
openshift:mainfrom
openshift-cloud-team:OCPBUGS-85416

Conversation

@mdbooth
Copy link
Copy Markdown
Contributor

@mdbooth mdbooth commented May 13, 2026

An actuator can already mutate its Machine argument to specificy an explicit Failed phase. However, because we don't also pass the error, updateStatus() cannot correctly set ErrorMessage and ErrorReason.

Summary by CodeRabbit

  • Bug Fixes

    • Machine controller now properly captures and reports error details in machine status when actuator operations fail during reconciliation.
  • Tests

    • Expanded test coverage to validate error messaging in actuator failure scenarios and ensure status reporting is accurate.

An actuator can already mutate its Machine argument to specificy an
explicit Failed phase. However, because we don't also pass the error,
updateStatus() cannot correctly set ErrorMessage and ErrorReason.
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@mdbooth: This pull request references Jira Issue OCPBUGS-85416, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

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 openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Walkthrough

The machine controller now propagates errors from failed actuator operations (Exists and Update) to the Machine status patch, enabling error messages to appear in the status. Test infrastructure and test cases are extended to inject actuator errors and validate error messaging.

Changes

Error Propagation and Failure Status Reporting

Layer / File(s) Summary
Error propagation in reconciliation
pkg/controller/machine/controller.go
When actuator.Exists or actuator.Update fails, the controller now passes the encountered error to updateStatus as the failureCause argument instead of nil, enabling error reason and message fields to be populated in the Machine status patch.
Test actuator error injection and hooks
pkg/controller/machine/testactuator.go
TestActuator struct and methods extended with ExistsErr, UpdateErr, ExistsMachineHook, and UpdateMachineHook fields to enable test-driven error injection and custom logic execution during operation boundaries. Exists and Update methods now invoke hooks and return configurable errors.
Test validation of error propagation
pkg/controller/machine/controller_test.go
TestReconcileRequest enhanced with existsErr, updateErr, existsMachineHook, updateMachineHook per-test-case fields. New test cases added for actuator "exists" and "update" failure paths that validate Machine status is set to PhaseFailed with appropriate ErrorMessage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 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 (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically summarizes the main change: enabling actuators to set terminal failure on Exists and Update operations, which directly corresponds to the code changes in the controller that now pass error causes to updateStatus().
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.
Stable And Deterministic Test Names ✅ Passed PR doesn't modify Ginkgo test files. The modified test file (controller_test.go) uses standard Go testing, not Ginkgo. Test names are stable and deterministic.
Test Structure And Quality ✅ Passed Tests meet quality standards: isolated error scenarios, proper setup via t.Run, meaningful assertions with case names, appropriate context usage, and consistency with codebase patterns.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests are added in this PR. Changes are limited to unit tests in pkg/controller/machine/ using standard Go testing package, not Ginkgo. The check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR does not add new Ginkgo e2e tests. It only modifies standard Go unit tests in controller_test.go and test helpers in testactuator.go. The SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed Changes are to Machine controller error handling logic only. No scheduling constraints, manifests, affinity rules, or topology assumptions introduced.
Ote Binary Stdout Contract ✅ Passed The PR does not violate the OTE Binary Stdout Contract. The OTE binary properly initializes logging via logs.InitLogs() with no stdout writes in process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR adds no new Ginkgo e2e tests. Changes are to Go standard unit tests (testing.T) and controller code, so the IPv6/disconnected network check is not applicable.

✏️ 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

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 13, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@mdbooth
Copy link
Copy Markdown
Contributor Author

mdbooth commented May 13, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@mdbooth: This pull request references Jira Issue OCPBUGS-85416, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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
Copy Markdown
Contributor

@mdbooth: This pull request references Jira Issue OCPBUGS-85416, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

An actuator can already mutate its Machine argument to specificy an explicit Failed phase. However, because we don't also pass the error, updateStatus() cannot correctly set ErrorMessage and ErrorReason.

Summary by CodeRabbit

  • Bug Fixes

  • Machine controller now properly captures and reports error details in machine status when actuator operations fail during reconciliation.

  • Tests

  • Expanded test coverage to validate error messaging in actuator failure scenarios and ensure status reporting is accurate.

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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 13, 2026

[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 mdbooth 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

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.

🧹 Nitpick comments (1)
pkg/controller/machine/controller_test.go (1)

647-653: ⚡ Quick win

Add a negative assertion for unexpected status.errorMessage.

Line 647 validates only positive cases. Add an else branch to assert machine.Status.ErrorMessage stays nil when no message is expected.

Proposed test hardening
 			if tc.expected.errorMessage != nil {
 				if machine.Status.ErrorMessage == nil {
 					t.Errorf("Case %s. Expected errorMessage %q, got nil", tc.request.Name, *tc.expected.errorMessage)
 				} else if *machine.Status.ErrorMessage != *tc.expected.errorMessage {
 					t.Errorf("Case %s. Got errorMessage: %q, expected: %q", tc.request.Name, *machine.Status.ErrorMessage, *tc.expected.errorMessage)
 				}
+			} else if machine.Status.ErrorMessage != nil {
+				t.Errorf("Case %s. Expected nil errorMessage, got %q", tc.request.Name, *machine.Status.ErrorMessage)
 			}
🤖 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 `@pkg/controller/machine/controller_test.go` around lines 647 - 653, The test
currently only checks when tc.expected.errorMessage is non-nil; add an else
branch after that check to assert that machine.Status.ErrorMessage is nil when
no error message is expected (i.e., when tc.expected.errorMessage == nil), using
the same test case context (tc.request.Name) and failing the test if
machine.Status.ErrorMessage is non-nil to prevent unexpected error messages
leaking into the status.
🤖 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 `@pkg/controller/machine/controller_test.go`:
- Around line 647-653: The test currently only checks when
tc.expected.errorMessage is non-nil; add an else branch after that check to
assert that machine.Status.ErrorMessage is nil when no error message is expected
(i.e., when tc.expected.errorMessage == nil), using the same test case context
(tc.request.Name) and failing the test if machine.Status.ErrorMessage is non-nil
to prevent unexpected error messages leaking into the status.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 9bcf11d5-6d5c-4d6d-825d-33bb4b37040c

📥 Commits

Reviewing files that changed from the base of the PR and between 7f40a74 and 88a744d.

📒 Files selected for processing (3)
  • pkg/controller/machine/controller.go
  • pkg/controller/machine/controller_test.go
  • pkg/controller/machine/testactuator.go

@mdbooth
Copy link
Copy Markdown
Contributor Author

mdbooth commented May 13, 2026

/hold until we validate openshift/machine-api-provider-azure#193

@mdbooth mdbooth marked this pull request as ready for review May 13, 2026 14:11
@openshift-ci openshift-ci Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 13, 2026
@openshift-ci openshift-ci Bot requested review from nrb and theobarberbany May 13, 2026 14:11
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 13, 2026

@mdbooth: 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.

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants