Skip to content

Add an integration test for node deletion - #1126

Open
aaronfern wants to merge 1 commit into
gardener:masterfrom
aaronfern:node_del_it
Open

Add an integration test for node deletion#1126
aaronfern wants to merge 1 commit into
gardener:masterfrom
aaronfern:node_del_it

Conversation

@aaronfern

Copy link
Copy Markdown
Member

What this PR does / why we need it:
This PR add an integration test to verify if machine deletion happens when node deletion is triggered

Which issue(s) this PR fixes:
Fixes partially #1123

Special notes for your reviewer:

Release note:

Added an integration test to validate machine deletion when it's corresponding node is deleted

@aaronfern
aaronfern requested a review from a team as a code owner July 27, 2026 13:03
@gardener-prow

gardener-prow Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

@gardener-prow gardener-prow Bot added do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 27, 2026
@aaronfern aaronfern added kind/test Test and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 27, 2026
@gardener-prow gardener-prow Bot added cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jul 27, 2026

@thiyyakat thiyyakat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the changes! The test looks good to me. I just had a few questions about possible behaviour.

Comment thread go.mod
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This dependency gets removed on running go mod tidy like in the other PR.

Comment on lines +743 to +754
ginkgo.By("Waiting until number of ready nodes is 1 more than initial nodes")
gomega.Eventually(
c.TargetCluster.GetNumberOfNodes,
c.timeout,
c.pollingInterval).
Should(gomega.BeNumerically("==", initialNodes+1))

gomega.Eventually(
c.TargetCluster.GetNumberOfReadyNodes,
c.timeout,
c.pollingInterval).
Should(gomega.BeNumerically("==", initialNodes+1))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just out of curiosity, why are there separate Eventually checks for GetNumberOfNodes and GetNumberOfReadyNodes? Does the latter not subsume the first check? I can see it is being done elsewhere too, just wanted to understand rationale.

gomega.Expect(err).To(gomega.BeNil())

ginkgo.By("Deleting node associated with test-machine")
err = c.TargetCluster.Clientset.CoreV1().Nodes().Delete(ctx, existingMachine.Labels["node"], metav1.DeleteOptions{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a race condition possible here? existingMachine.Labels["node"] may get set after a node is ready, in which case Delete will fail and leave an orphaned resource. You could avoid this by waiting for the label to get set on the machine before calling delete.

gomega.Expect(err).To(gomega.BeNil())

ginkgo.By("Deleting node associated with test-machine")
err = c.TargetCluster.Clientset.CoreV1().Nodes().Delete(ctx, existingMachine.Labels["node"], metav1.DeleteOptions{})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
err = c.TargetCluster.Clientset.CoreV1().Nodes().Delete(ctx, existingMachine.Labels["node"], metav1.DeleteOptions{})
err = c.TargetCluster.Clientset.CoreV1().Nodes().Delete(ctx, existingMachine.Labels[v1alpha1.NodeLabelKey], metav1.DeleteOptions{})

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

Labels

cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/test Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants