Skip to content

Conversation

@olamilekan000
Copy link
Contributor

Summary

change fixes TestValidatingAdmissionPolicyCrossWorkspaceAPIBinding by creating the default namespace if it doesn't exist.

What Type of PR Is This?

/kind bug

Related Issue(s)

Fixes 3753

Release Notes

Fixed TestValidatingAdmissionPolicyCrossWorkspaceAPIBinding flaky test.

@kcp-ci-bot kcp-ci-bot added dco-signoff: yes Indicates the PR's author has signed the DCO. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Dec 10, 2025
@kcp-ci-bot
Copy link
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 ntnn for approval. For more information see the Kubernetes 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

@kcp-ci-bot kcp-ci-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 10, 2025
@olamilekan000
Copy link
Contributor Author

/retest

Comment on lines +295 to +304
t.Logf("Creating default namespace in target workspace")
defaultNS := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
},
}
_, err = kubeClusterClient.Cluster(targetPath).CoreV1().Namespaces().Create(ctx, defaultNS, metav1.CreateOptions{})
if err != nil && !errors.IsAlreadyExists(err) {
require.NoError(t, err, "failed to create default namespace")
}
Copy link
Member

Choose a reason for hiding this comment

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

This and the change below is more a bandaid instead of a fix. It'd be better to address the root cause of the missing namespace.

Looking at this code this has been a problem in the past:

t.Logf("Wait until the %q workspace is ready", workspace.Name)
kcptestinghelpers.Eventually(t, func() (bool, string) {
workspace, err := server.kcpClusterClient.Cluster(orgPath).TenancyV1alpha1().Workspaces().Get(ctx, workspace.Name, metav1.GetOptions{})
require.NoError(t, err, "failed to get workspace")
if actual, expected := workspace.Status.Phase, corev1alpha1.LogicalClusterPhaseReady; actual != expected {
return false, fmt.Sprintf("workspace phase is %s, not %s", actual, expected)
}
return workspace.Status.Phase == corev1alpha1.LogicalClusterPhaseReady, fmt.Sprintf("workspace phase is %s", workspace.Status.Phase)
}, wait.ForeverTestTimeout, time.Millisecond*100, "failed to wait for workspace %s to become ready", orgPath.Join(workspace.Name))
workspaceCluster := orgPath.Join(workspace.Name)
t.Logf("Wait for default namespace to be created")
kcptestinghelpers.Eventually(t, func() (bool, string) {
_, err := server.kubeClusterClient.Cluster(workspaceCluster).CoreV1().Namespaces().Get(ctx, "default", metav1.GetOptions{})
if err != nil {
return false, err.Error()
}
return true, ""
}, wait.ForeverTestTimeout, 100*time.Millisecond, "default namespace was never created")

Instead of waiting on the namespace it would be preferable to inspect why the workspace phase is set to ready before the default namespace is present.

_, err = kcpClusterClient.Cluster(sourcePath).ApisV1alpha2().APIExports().Create(ctx, cowboysAPIExport, metav1.CreateOptions{})
require.NoError(t, err)

t.Logf("Creating default namespace in target workspace")
Copy link
Contributor

Choose a reason for hiding this comment

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

yap, this is not the fix. + it will try to create namespace where workspace bootstrap process does the same. THis might cause other isues

@mjudeikis
Copy link
Contributor

/test all

@mjudeikis
Copy link
Contributor

/retest

@mjudeikis
Copy link
Contributor

my attempt to fix this #3777
I think informers might been leaking a bit in the implementation

@olamilekan000
Copy link
Contributor Author

Fixed by: #3777

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

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix TestValidatingAdmissionPolicyCrossWorkspaceAPIBinding flaky test

4 participants