Skip to content

🌱 Add e2e tests for forced detachment#3072

Open
dtantsur wants to merge 2 commits intometal3-io:mainfrom
dtantsur:force-detachment-e2e
Open

🌱 Add e2e tests for forced detachment#3072
dtantsur wants to merge 2 commits intometal3-io:mainfrom
dtantsur:force-detachment-e2e

Conversation

@dtantsur
Copy link
Copy Markdown
Member

@dtantsur dtantsur commented Mar 12, 2026

This change adds tests for two aspects of forced detachment:

  1. Detaching during provisioning, deleting the host afterwards
  2. Detaching during provisioning, re-attaching and continuing

To be able to run the verification at the right moment, the test
accesses Ironic directly and checks its internal state. A new helper
is introduced for that.

Follow-up to #2955
Assisted-By: Claude Code (commercial license)

@metal3-io-bot metal3-io-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2026
@metal3-io-bot
Copy link
Copy Markdown
Contributor

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

@metal3-io-bot metal3-io-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 12, 2026
@metal3-io-bot metal3-io-bot added the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Apr 17, 2026
@dtantsur dtantsur force-pushed the force-detachment-e2e branch from 13bb2e2 to aaac6ac Compare April 21, 2026 14:25
@metal3-io-bot metal3-io-bot removed the needs-rebase Indicates that a PR cannot be merged because it has merge conflicts with HEAD. label Apr 21, 2026
@dtantsur dtantsur force-pushed the force-detachment-e2e branch 2 times, most recently from 15d7cef to 7e82b68 Compare April 29, 2026 10:56
@metal3-io-bot metal3-io-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 29, 2026
@dtantsur dtantsur force-pushed the force-detachment-e2e branch from 4adac2c to c97da29 Compare April 29, 2026 17:36
@dtantsur
Copy link
Copy Markdown
Member Author

/retest

Whole bunch of timeouts when registering. Unrelated?

@dtantsur
Copy link
Copy Markdown
Member Author

/retest

A case of #3195 again. Let's collect some statistics.

@dtantsur dtantsur changed the title WIP e2e tests for forced detachment 🌱 Add e2e tests for forced detachment Apr 30, 2026
@metal3-io-bot metal3-io-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 30, 2026
@tuminoid tuminoid requested a review from Copilot May 2, 2026 15:23
@tuminoid
Copy link
Copy Markdown
Member

tuminoid commented May 2, 2026

/retest

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new end-to-end coverage for “forced detachment” behavior during provisioning, including scenarios for deleting after detachment and re-attaching to continue provisioning. To make the tests less timing-dependent, it introduces a direct Ironic API polling helper and wires a new e2e namespace/overlay for the test suite.

Changes:

  • Add forced-detachment e2e tests that detach during provisioning and validate follow-up behaviors (delete/re-attach/continue).
  • Introduce an Ironic client + polling helper (via Gophercloud) to observe Ironic node provision state during tests.
  • Extend e2e overlay/config to include the new force-detach namespace and test-specific intervals.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/go.mod Adds Gophercloud dependency for direct Ironic API access in e2e tests.
test/go.sum Updates sums for the new test-module dependency.
test/e2e/ironic_helpers.go New helper for creating an Ironic client and polling node provision state.
test/e2e/forced_detachment_test.go New e2e test cases covering forced detachment during provisioning (delete and re-attach flows).
test/e2e/config/ironic.yaml Adds force-detach-specific polling intervals to reduce flakes with real Ironic timing.
config/overlays/e2e/namespaced-manager-patch.yaml Adds force-detach to WATCH_NAMESPACE for namespaced e2e runs.
config/overlays/e2e/kustomization.yaml Registers the new force-detach overlay in the e2e overlay set.
config/overlays/e2e/force-detach/namespace.yaml Creates the force-detach namespace for e2e runs.
config/overlays/e2e/force-detach/kustomization.yaml New kustomization overlay to apply RBAC + namespace for the test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/e2e/forced_detachment_test.go
Comment on lines +117 to +122
if bmh.Annotations == nil {
bmh.Annotations = make(map[string]string, 1)
}
bmh.Annotations["baremetalhost.metal3.io/detached"] = "{\"force\": true}"

Expect(helper.Patch(ctx, &bmh)).To(Succeed())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This avoids drift if the annotation schema changes

This is exactly a thing I'd prefer to catch in the tests. I'll update the constants though.

Comment thread test/e2e/forced_detachment_test.go
Comment thread test/e2e/forced_detachment_test.go Outdated
Comment thread test/e2e/forced_detachment_test.go
Comment thread test/e2e/ironic_helpers.go
@dtantsur dtantsur force-pushed the force-detachment-e2e branch from c97da29 to 1168b29 Compare May 7, 2026 14:28
dtantsur added 2 commits May 8, 2026 18:28
Exercise forced detachment followed by deletion, new enrollment and
finished provisioning.

Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
The test must wait for the Ironic Node to leave the "available" state,
otherwise it won't test the forced detachment, but rather the regular
one.

Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

UndesiredStates: []metal3api.OperationalStatus{
metal3api.OperationalStatusError,
},
}, e2eConfig.GetIntervals(specName, "wait-detached")...)
Comment on lines 82 to +84
default/wait-detached: [ "20s", "10ms" ]
# NOTE(dtantsur) since provisionRequeueDelay is 10s, 20s may not be enough for forced detachment on real Ironic.
default/wait-force-detached: [ "40s", "1s" ]
Comment on lines +114 to +116
By("Adding the detached annotation")
helper, err := patch.NewHelper(&bmh, clusterProxy.GetClient())
Expect(err).NotTo(HaveOccurred())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants