Skip to content
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

E2E: use ServiceDiscovery CR to determine if clusterset IP is enabled #1653

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

vthapar
Copy link
Contributor

@vthapar vthapar commented Oct 1, 2024

...in E2E tests coz lighthouse agent may not be present if service-discovery is disabled.

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr1653/vthapar/clustersetip-e2e-fix
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

names.ServiceDiscoveryComponent, metav1.GetOptions{})
for _, submClient := range SubmarinerClients {
framework.AwaitUntil("Get clustersetIP enabled Configuration", func() (interface{}, error) {
unstructuredSubmarinerConfig, err := submClient.Get(context.TODO(),
Copy link
Contributor

Choose a reason for hiding this comment

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

If only SD is installed than the Submariner CR isn't created so I think we should look for the ServiceDiscovery CR. Of course if SD isn't installed then that CR won't exist. So we can either Get the ServiceDiscovery CR without using use AwaitUntil and set ClusterSetIPEnabled = if ServiceDiscovery found && ServiceDiscovery.Spec.ClusterSetIPEnabled OR, preferably, lazily do this check from BeforeEach:

    var clusterSetIPEnabled = atomic.Pointer[bool]{}
    ...
    func IsClusterSetIPEnabled() bool {
	enabledPtr := clusterSetIPEnabled.Load()
	if enabledPtr != nil {
		return *enabledPtr
	}

	gvr, _ := schema.ParseResourceArg("servicediscoveries.v1alpha1.submariner.io")
	sdClient := framework.DynClients[0].Resource(*gvr).Namespace(framework.TestContext.SubmarinerNamespace)

	framework.AwaitUntil("find service-discovery resource", func() (interface{}, error) {
		return sdClient.Get(context.TODO(), "service-discovery", metav1.GetOptions{})
	}, func(result interface{}) (bool, string, error) {
		enabled, _, err := unstructured.NestedBool(result.(*unstructured.Unstructured).Object, "spec", "clustersetIPEnabled")
		if err != nil {
			return false, "", err
		}

		clusterSetIPEnabled.Store(ptr.To(enabled))

		return true, "", nil
	})

	return *clusterSetIPEnabled.Load()
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

I pushed this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set ClusterSetIPEnabled = if ServiceDiscovery found && ServiceDiscovery.Spec.ClusterSetIPEnabled

This works better.

...in E2E tests coz lighthouse agent may not be present if
service-discovery is disabled.

Signed-off-by: Vishal Thapar <5137689+vthapar@users.noreply.github.com>
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@tpantelis tpantelis changed the title Use Submariner CR for clustersetip flag E2E: use ServiceDiscovery CR to determine if clusterset IP is enabled Oct 1, 2024
@vthapar vthapar enabled auto-merge (rebase) October 1, 2024 18:00
Copy link
Contributor Author

@vthapar vthapar left a comment

Choose a reason for hiding this comment

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

looks good, but I can't approve the review.

@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label Oct 1, 2024
@vthapar vthapar merged commit 067279c into submariner-io:devel Oct 1, 2024
27 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr1653/vthapar/clustersetip-e2e-fix]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-handled backport-needed ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants