Skip to content

Conversation

@ratnam915
Copy link

This PR has been created as a solution for the Jira ticket :

https://issues.redhat.com/browse/SREP-2356

The PR contains the introduction of a new webhook i.e network-operator-validation which would prevent user modifications to network.operator CRD for critical fields even for cluster-admins.

Below are the fields that are covered as part of the webhook:

spec.migration.networkType
spec.migration.mode
spec.migration.features
spec.migration.mtu.network
spec.migration.mtu.machine

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 5, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 5, 2026

@ratnam915: This pull request references SREP-2356 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 task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This PR has been created as a solution for the Jira ticket :

https://issues.redhat.com/browse/SREP-2356

The PR contains the introduction of a new webhook i.e network-operator-validation which would prevent user modifications to network.operator CRD for critical fields even for cluster-admins.

Below are the fields that are covered as part of the webhook:

spec.migration.networkType
spec.migration.mode
spec.migration.features
spec.migration.mtu.network
spec.migration.mtu.machine

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 openshift-ci bot requested review from Mhodesty and xiaoyu74 January 5, 2026 05:44
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 5, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ratnam915
Once this PR has been reviewed and has the lgtm label, please assign mitalibhalla 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

}

// Check if critical migration fields have been modified
if hasCriticalMigrationFieldChanges(oldObject, object) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The concern I have is that this webhook blocks everyone including backplane elevate which I would assume is necessary for SREP to have, in case we need to modify those fields for whatever reason.

ocm backplane elevate "testing webhook" -- patch network.operator.openshif
t.io cluster --type='merge' --patch '{"spec":{"migration":{"networkType":"
OpenShiftSDN"}}}'
Error from server (Forbidden): admission webhook "network-operator-validation.managed.openshift.io" denied the request: Modification of critical migration fields (spec.migration.networkType and related migration configuration) is not allowed, even for cluster-admin users. These fields are managed by the Cluster Network Operator and manual changes can disrupt CNI migrations.
ERRO[0002] exit status 1   

We could introduce some logic e.g.

to allow backplane elevate to modify it, unless there is a justification why this is blocked?

Copy link
Author

Choose a reason for hiding this comment

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

@diakovnec : The acceptance criteria for the ticket mentions:

'Webhook prevents even cluster-admin users from modifying critical fields'

However as suggested we could add this logic if necessary

Copy link
Contributor

Choose a reason for hiding this comment

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

I think SREP should have a way to have access to modify those objects
could be similar to what we did e.g.

// Users allowed to delete protected ClusterRoles


const (
WebhookName string = "network-operator-validation"
docString string = `Managed OpenShift customers may not modify critical fields in the network.operator CRD (such as spec.migration.networkType) because it can disrupt Cluster Network Operator operations and CNI migrations. Only backplane-cluster-admin and SRE service accounts are allowed to modify these critical fields. Regular cluster-admin users (system:admin) are explicitly blocked.`
Copy link
Contributor

Choose a reason for hiding this comment

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

system:admin is not on the list of allowed, hence the massage is missleading

Copy link
Author

Choose a reason for hiding this comment

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

Hey @diakovnec : The message explicity states : 'Regular cluster-admin users (system:admin) are explicitly blocked'

Do we still need any changes around this?

}

// Also check request.UserInfo.Groups directly (some webhooks use this pattern)
allGroups := append(request.AdmissionRequest.UserInfo.Groups, request.UserInfo.Groups...)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this might create a duplicates of records if both username and groups returns with the same value e.g., I've looked into other webhooks and its handled with something like

// isAllowedUserGroup checks if the user or group is allowed to perform the action
or
// isAllowedUser checks if the user or group is allowed to perform the action
func isAllowedUserGroup(request admissionctl.Request) bool {

I don't think its critical but maybe we can implement similar pattern.

Copy link
Author

Choose a reason for hiding this comment

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

@diakovnec : Changes have been made based on the examples you have shared and also to make sure any duplication doesn't happen

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 14, 2026

@ratnam915: all tests passed!

Full PR test history. Your PR dashboard.

Details

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.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants