Skip to content

SREP-1622: Fix endpoint admission test namespace creation for ROSA #30134

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

Amarthya-v
Copy link

@Amarthya-v Amarthya-v commented Aug 19, 2025

Check if namespace exists before creation to prevent unnecessary webhook calls while maintaining same test behavior.

Fixes: SREP-1622

@arghosh93
Copy link

/retitle OCPBUGS-60654: Fix endpoint admission test namespace creation for ROSA

@openshift-ci openshift-ci bot changed the title Fix endpoint admission test namespace creation for ROSA OCPBUGS-60654: Fix endpoint admission test namespace creation for ROSA Aug 20, 2025
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 20, 2025
@openshift-ci-robot
Copy link

@Amarthya-v: This pull request references Jira Issue OCPBUGS-60654, which is invalid:

  • expected the bug to target the "4.20.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Check if namespace exists before creation to prevent unnecessary webhook calls while maintaining same test behavior.

Fixes: OCPBUGS-60654

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 openshift-eng/jira-lifecycle-plugin repository.

_, err := adminClient.CoreV1().Namespaces().Get(context.Background(), namespace, metav1.GetOptions{})
if err != nil {
if errors.IsNotFound(err) {
_, err = adminClient.CoreV1().Namespaces().Create(context.Background(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, metav1.CreateOptions{})

Choose a reason for hiding this comment

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

If the webhook does not allow creating a namespace, then I would expect this to also fail if the namespace does not exist by that time.
However I think kube-system namespace should always be there. Are you counting on that fact?

Copy link
Author

Choose a reason for hiding this comment

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

@arghosh93 Yes, this fix specifically addresses the kube-system namespace case, which Always exists in OpenShift/Kubernetes clusters and is being unnecessarily created by the test, triggering the ROSA webhook
now it gets checked first before attempting creation.

For test-specific namespaces that don't exist, the create path still works as before. The webhook only blocks creation in managed namespaces like kube-system.

The failing ROSA jobs were specifically hitting this error when trying to create kube-system:

'''admission webhook "namespace-validation.managed.openshift.io" denied the request:
Prevented from accessing Red Hat managed namespaces

This fix avoids that unnecessary webhook call entirely for existing namespaces.'''

So the fix targets the specific scenario causing ROSA CI failures without breaking the general functionality.

@arghosh93
Copy link

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2025
@Amarthya-v
Copy link
Author

/assign kyrtapz

@kyrtapz
Copy link
Contributor

kyrtapz commented Aug 21, 2025

@Amarthya-v why is the bug closed?

if err != nil {
return nil, nil, err
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: there is no need for the else here.
To decrease the nestedness maybe we could go with:

	if err != nil {
		if !errors.IsNotFound(err) {
		    return nil, nil, err
	    }
		_, err = adminClient.CoreV1().Namespaces().Create(context.Background(), &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, metav1.CreateOptions{})
		if err != nil {
			return nil, nil, err
		}
	}

Copy link
Author

Choose a reason for hiding this comment

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

@kyrtapz Updated! Much cleaner now. Thanks for the suggestion.

@@ -210,4 +217,4 @@ func getClientForServiceAccount(adminClient kubernetes.Interface, clientConfig *
}

return kubeClientset, saClientConfig, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: missing newline

Copy link
Author

Choose a reason for hiding this comment

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

Added the missing newline. thanks!

@Amarthya-v
Copy link
Author

@Amarthya-v why is the bug closed?

The bug was closed because Trevor reverted the webhook temporarily to unblock CI.

This PR is the permanent fix - once merged, Trevor can safely re-enable the webhook without breaking ROSA CI.

It's part of a coordinated plan: revert → fix test → re-enable webhook.

Avoid attempting to create existing namespaces like kube-system
which triggers managed-cluster-validating-webhooks in ROSA.

Check if namespace exists before creation to prevent unnecessary
webhook calls while maintaining same test behavior.

Fixes: OCPBUGS-60654
@Amarthya-v Amarthya-v force-pushed the fix-endpoint-admission-namespace-creation branch from d09ba2e to 6389c5f Compare August 21, 2025 16:59
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2025
@kyrtapz
Copy link
Contributor

kyrtapz commented Aug 21, 2025

@Amarthya-v why is the bug closed?

The bug was closed because Trevor reverted the webhook temporarily to unblock CI.

This PR is the permanent fix - once merged, Trevor can safely re-enable the webhook without breaking ROSA CI.

It's part of a coordinated plan: revert → fix test → re-enable webhook.

You need to address the jira/invalid-bug label on the PR.
#30134 (comment)

@Amarthya-v Amarthya-v changed the title OCPBUGS-60654: Fix endpoint admission test namespace creation for ROSA SREP-1622: Fix endpoint admission test namespace creation for ROSA Aug 21, 2025
@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Aug 21, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 21, 2025

@Amarthya-v: This pull request references SREP-1622 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.20.0" version, but no target version was set.

In response to this:

Check if namespace exists before creation to prevent unnecessary webhook calls while maintaining same test behavior.

Fixes: OCPBUGS-60654

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 21, 2025

@Amarthya-v: This pull request references SREP-1622 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.20.0" version, but no target version was set.

In response to this:

Check if namespace exists before creation to prevent unnecessary webhook calls while maintaining same test behavior.

Fixes: SREP-1622

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 openshift-eng/jira-lifecycle-plugin repository.

1 similar comment
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 21, 2025

@Amarthya-v: This pull request references SREP-1622 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.20.0" version, but no target version was set.

In response to this:

Check if namespace exists before creation to prevent unnecessary webhook calls while maintaining same test behavior.

Fixes: SREP-1622

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 openshift-eng/jira-lifecycle-plugin repository.

@Amarthya-v
Copy link
Author

@Amarthya-v why is the bug closed?

The bug was closed because Trevor reverted the webhook temporarily to unblock CI.
This PR is the permanent fix - once merged, Trevor can safely re-enable the webhook without breaking ROSA CI.
It's part of a coordinated plan: revert → fix test → re-enable webhook.

You need to address the jira/invalid-bug label on the PR. #30134 (comment)

feedback addressed and Jira issue resolved.

@kyrtapz
Copy link
Contributor

kyrtapz commented Aug 21, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2025
Copy link
Contributor

openshift-ci bot commented Aug 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Amarthya-v, arghosh93, kyrtapz

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2025
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD b53c4b6 and 2 for PR HEAD 6389c5f in total

@Amarthya-v
Copy link
Author

/override ci/prow/e2e-aws-ovn-fips

Copy link
Contributor

openshift-ci bot commented Aug 21, 2025

@Amarthya-v: Amarthya-v unauthorized: /override is restricted to Repo administrators, approvers in top level OWNERS file, and the following github teams:openshift: openshift-release-oversight openshift-staff-engineers openshift-sustaining-engineers.

In response to this:

/override ci/prow/e2e-aws-ovn-fips

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-sigs/prow repository.

@Amarthya-v
Copy link
Author

/test e2e-aws-ovn-fips

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD b53c4b6 and 2 for PR HEAD 6389c5f in total

@Amarthya-v
Copy link
Author

/skip

1 similar comment
@Amarthya-v
Copy link
Author

/skip

@Amarthya-v
Copy link
Author

/test e2e-aws-ovn-serial-1of2

@Amarthya-v
Copy link
Author

/test e2e-gcp-ovn

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0dfa8e5 and 1 for PR HEAD 6389c5f in total

@Amarthya-v
Copy link
Author

/skip

@Amarthya-v
Copy link
Author

/test e2e-vsphere-ovn

Copy link
Contributor

openshift-ci bot commented Aug 22, 2025

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

Test name Commit Details Required Rerun command
ci/prow/e2e-metal-ipi-serial-ovn-ipv6-2of2 6389c5f link false /test e2e-metal-ipi-serial-ovn-ipv6-2of2
ci/prow/e2e-aws-ovn-kube-apiserver-rollout 6389c5f link false /test e2e-aws-ovn-kube-apiserver-rollout
ci/prow/e2e-metal-ipi-ovn-dualstack-local-gateway 6389c5f link false /test e2e-metal-ipi-ovn-dualstack-local-gateway
ci/prow/e2e-gcp-ovn-techpreview 6389c5f link false /test e2e-gcp-ovn-techpreview
ci/prow/e2e-metal-ipi-ovn-kube-apiserver-rollout 6389c5f link false /test e2e-metal-ipi-ovn-kube-apiserver-rollout
ci/prow/e2e-metal-ipi-serial-2of2 6389c5f link false /test e2e-metal-ipi-serial-2of2
ci/prow/e2e-aws-ovn-edge-zones 6389c5f link false /test e2e-aws-ovn-edge-zones
ci/prow/e2e-gcp-ovn-techpreview-serial-2of2 6389c5f link false /test e2e-gcp-ovn-techpreview-serial-2of2
ci/prow/e2e-metal-ipi-serial-ovn-ipv6-1of2 6389c5f link false /test e2e-metal-ipi-serial-ovn-ipv6-1of2
ci/prow/e2e-aws-disruptive 6389c5f link false /test e2e-aws-disruptive
ci/prow/e2e-hypershift-conformance 6389c5f link false /test e2e-hypershift-conformance
ci/prow/e2e-metal-ipi-virtualmedia 6389c5f link false /test e2e-metal-ipi-virtualmedia
ci/prow/e2e-aws-ovn-single-node 6389c5f link false /test e2e-aws-ovn-single-node
ci/prow/e2e-vsphere-ovn 6389c5f link true /test e2e-vsphere-ovn
ci/prow/okd-scos-e2e-aws-ovn 6389c5f link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-metal-ipi-ovn-dualstack 6389c5f link false /test e2e-metal-ipi-ovn-dualstack
ci/prow/e2e-metal-ipi-ovn 6389c5f link false /test e2e-metal-ipi-ovn
ci/prow/e2e-metal-ipi-serial-1of2 6389c5f link false /test e2e-metal-ipi-serial-1of2

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@Amarthya-v
Copy link
Author

/lgtm

Thanks Patryk!! the failure in ci/prow/e2e-vsphere-ovn My PR doesn’t modify networking, and I see the same failure in other jobs today. This looks like infra/kernel flake rather than my change. Requesting test override.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0dfa8e5 and 2 for PR HEAD 6389c5f in total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants