Skip to content

Cleanup legacy controller deployments in test teardown #1834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tiffanny29631
Copy link
Contributor

Improve test reliability by deleting legacy reconciler-manager and resource-group-controller deployments in nomos migrate test cleanup.

Legacy ConfigManagement installed during nomos migrate test sets readiness on these controllers, which isn’t reliably cleaned up after tests. Removing both deployments ensures a fresh Config Sync install instead of patching, reducing flakiness and side effects between tests.

Improve test reliability by deleting legacy reconciler-manager and resource-group-controller deployments in test cleanup.
Legacy ConfigManagement sets readiness on these controllers, which isn’t reliably cleaned up after tests.
Removing both deployments ensures a fresh Config Sync install instead of patching, reducing flakiness and side effects between tests.
Copy link

[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 ask for approval from tiffanny29631. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@google-oss-prow google-oss-prow bot requested review from mikebz and sdowell August 19, 2025 23:44
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @tiffanny29631, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the reliability of end-to-end tests, specifically those related to nomos migrate and ACM uninstallation. It addresses test flakiness by ensuring that legacy reconciler-manager and resource-group-controller deployments are explicitly deleted during test teardown. This guarantees a clean slate for Config Sync installations in subsequent test runs, preventing issues caused by lingering states from previous tests.

Highlights

  • Improved Test Reliability: Enhances the stability of nomos migrate and ACM uninstall end-to-end tests by preventing state leakage between test runs.
  • Explicit Deployment Deletion: Introduces logic to explicitly delete reconciler-manager and resource-group-controller deployments during test cleanup.
  • Ensuring Clean State: Guarantees a fresh Config Sync installation for each test, avoiding reliance on patching or implicit cleanup of legacy components.
  • Targeted Cleanup: The cleanup logic is applied to the Cleanup functions of TestNomosMigrate, TestNomosMigrateMonoRepo, and TestACMUninstallScript.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds cleanup logic to delete legacy reconciler-manager and resource-group-controller deployments in several e2e tests. This improves test reliability by ensuring a clean state. The implementation is correct, but the same cleanup logic is duplicated across three test functions. I've suggested refactoring this duplicated code into a helper function to improve maintainability.

Comment on lines +1305 to +1321
// Legacy ConfigManagement sets readiness on reconciler-manager and resource-group-controller,
// which isn't reliably cleaned up after tests. Delete both to ensure a fresh
// install instead of patching.
rmDeployment := k8sobjects.DeploymentObject(
core.Name(reconcilermanager.ManagerName),
core.Namespace(configsync.ControllerNamespace),
)
rgDeployment := k8sobjects.DeploymentObject(
core.Name(configmanagement.RGControllerName),
core.Namespace(configmanagement.RGControllerNamespace),
)
if err := nt.KubeClient.Delete(rmDeployment); err != nil && !apierrors.IsNotFound(err) {
nt.T.Error(err)
}
if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
nt.T.Error(err)
}

Choose a reason for hiding this comment

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

medium

This cleanup logic is duplicated in TestNomosMigrateMonoRepo (lines 1490-1506) and TestACMUninstallScript (lines 1749-1765). To improve maintainability and reduce code duplication, consider extracting this logic into a local helper function within this file.

For example, you could create a function like this:

func deleteLegacyDeployments(nt *nomostest.NT) {
	nt.T.Helper()
	// Legacy ConfigManagement sets readiness on reconciler-manager and resource-group-controller,
	// which isn't reliably cleaned up after tests. Delete both to ensure a fresh
	// install instead of patching.
	rmDeployment := k8sobjects.DeploymentObject(
		core.Name(reconcilermanager.ManagerName),
		core.Namespace(configsync.ControllerNamespace),
	)
	rgDeployment := k8sobjects.DeploymentObject(
		core.Name(configmanagement.RGControllerName),
		core.Namespace(configmanagement.RGControllerNamespace),
	)
	if err := nt.KubeClient.Delete(rmDeployment); err != nil && !apierrors.IsNotFound(err) {
		nt.T.Error(err)
	}
	if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
		nt.T.Error(err)
	}
}

Then, you can replace the duplicated blocks in each T.Cleanup with a single call to deleteLegacyDeployments(nt).

}
if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
nt.T.Error(err)
}
if err := nomostest.InstallConfigSync(nt); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Deleting and recreating specific subcomponents is going to be error prone, as it doesn't guarantee the e2e client claims ownership of all fields for all objects which could have drifted. Perhaps using client side apply here when reinstalling would be a more thorough option

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm without the other PR it's hard to know whether further changes are effective or just false positive, some natural result from the standalone branching. I might need to add some check for the readiness field as well to verify it's actually removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest rebasing that PR on top of this one, then you can validate it works from the tests in the other PR

Copy link

@tiffanny29631: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kpt-config-sync-presubmit-e2e-multi-repo-test-group3 ab3731e link true /test kpt-config-sync-presubmit-e2e-multi-repo-test-group3

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/test-infra 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants