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

OCPBUGS-28920: Update ingressconfig_controller to use field Manager #2259

Merged

Conversation

npinaeva
Copy link
Member

@npinaeva npinaeva commented Feb 7, 2024

Update ingressconfig_controller to use subcontroller "ingress_controller"
for field management on Patch calls. It used to apply changes with
deprecated cluster-network-operator field manager, that was overridden
and removed by ApplyObject. Thus, labels applied to
openshift-host-network namespace were periodically removed.

On upgrade, ingress-owned labels will be merged with "cluster-network-operator/operconfig" Apply call here https://github.com/openshift/cluster-network-operator/blob/master/pkg/apply/apply.go#L139-L150 and removed as the new owner didn't specify them. On the next reconcile loop, ingress controller will re-apply the labels with the new fieldManager and everything should work fine ever after.

For some reason, ingress controller was last this that doesn't use apply logic, but Patches instead.

Should end up with something like this

  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:openshift.io/description: {}
          f:workload.openshift.io/allowed: {}
        f:labels:
          f:policy-group.network.openshift.io/host-network: {}
        f:ownerReferences:
          k:{"uid":"eae5d3b2-cf31-4bfa-940a-fa631adce87d"}: {}
    manager: cluster-network-operator/operconfig
    operation: Apply
    time: "2024-02-07T11:38:45Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:labels:
          f:network.openshift.io/policy-group: {}
          f:policy-group.network.openshift.io/ingress: {}
      f:spec: {}
    manager: cluster-network-operator/ingress_controller
    operation: Apply
    time: "2024-02-07T11:41:11Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:openshift.io/sa.scc.mcs: {}
          f:openshift.io/sa.scc.supplemental-groups: {}
          f:openshift.io/sa.scc.uid-range: {}
    manager: cluster-policy-controller
    operation: Update
    time: "2024-02-07T08:49:53Z"

@openshift-ci-robot openshift-ci-robot added jira/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Feb 7, 2024
@openshift-ci-robot
Copy link
Contributor

@npinaeva: This pull request references Jira Issue OCPBUGS-28920, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @anuragthehatter

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

In response to this:

with subcontroller "ingress_controller". It used to apply changes with deprecated cluster-network-operator field manager, that was overridden and removed by ApplyObject. Thus, labels applied to openshift-host-network namespace were periodically removed.

On upgrade, ingress-owned labels will be merged with "cluster-network-operator/operconfig" Apply call here https://github.com/openshift/cluster-network-operator/blob/master/pkg/apply/apply.go#L139-L150 and removed as the new owner didn't specify them. On the next reconcile loop, ingress controller will re-apply the labels with the new fieldManager and everything should work fine ever after.

Should end up with something like this

 managedFields:
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/description: {}
         f:workload.openshift.io/allowed: {}
       f:labels:
         f:policy-group.network.openshift.io/host-network: {}
       f:ownerReferences:
         k:{"uid":"eae5d3b2-cf31-4bfa-940a-fa631adce87d"}: {}
   manager: cluster-network-operator/operconfig
   operation: Apply
   time: "2024-02-07T11:38:45Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:labels:
         f:network.openshift.io/policy-group: {}
         f:policy-group.network.openshift.io/ingress: {}
     f:spec: {}
   manager: cluster-network-operator/ingress_controller
   operation: Apply
   time: "2024-02-07T11:41:11Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/sa.scc.mcs: {}
         f:openshift.io/sa.scc.supplemental-groups: {}
         f:openshift.io/sa.scc.uid-range: {}
   manager: cluster-policy-controller
   operation: Update
   time: "2024-02-07T08:49:53Z"

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
Contributor

@npinaeva: This pull request references Jira Issue OCPBUGS-28920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @anuragthehatter

In response to this:

with subcontroller "ingress_controller". It used to apply changes with deprecated cluster-network-operator field manager, that was overridden and removed by ApplyObject. Thus, labels applied to openshift-host-network namespace were periodically removed.

On upgrade, ingress-owned labels will be merged with "cluster-network-operator/operconfig" Apply call here https://github.com/openshift/cluster-network-operator/blob/master/pkg/apply/apply.go#L139-L150 and removed as the new owner didn't specify them. On the next reconcile loop, ingress controller will re-apply the labels with the new fieldManager and everything should work fine ever after.

For some reason, ingress controller was last this that doesn't use apply logic, but Patches instead.

Should end up with something like this

 managedFields:
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/description: {}
         f:workload.openshift.io/allowed: {}
       f:labels:
         f:policy-group.network.openshift.io/host-network: {}
       f:ownerReferences:
         k:{"uid":"eae5d3b2-cf31-4bfa-940a-fa631adce87d"}: {}
   manager: cluster-network-operator/operconfig
   operation: Apply
   time: "2024-02-07T11:38:45Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:labels:
         f:network.openshift.io/policy-group: {}
         f:policy-group.network.openshift.io/ingress: {}
     f:spec: {}
   manager: cluster-network-operator/ingress_controller
   operation: Apply
   time: "2024-02-07T11:41:11Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/sa.scc.mcs: {}
         f:openshift.io/sa.scc.supplemental-groups: {}
         f:openshift.io/sa.scc.uid-range: {}
   manager: cluster-policy-controller
   operation: Update
   time: "2024-02-07T08:49:53Z"

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.

Copy link
Contributor

@kyrtapz kyrtapz left a comment

Choose a reason for hiding this comment

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

Overall looks good.
We should probably also address the same issue here

return status.client.ClientFor(apply.GetClusterName(obj)).CRClient().Patch(ctx, obj, crclient.RawPatch(types.MergePatchType, patchData))

@@ -64,7 +63,8 @@ var _ reconcile.Reconciler = &ReconcileIngressConfigs{}
// ReconcileIngressConfigs watches for updates to ingress controller configuration
// and sets the network policy related labels on the openshift-host-network namespace
type ReconcileIngressConfigs struct {
client crclient.Client
client cnoclient.Client
mgr manager.Manager
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding the manager to the controller you can extract the client from cnoclient.Client with client.Default().CRCClient()

// The right way to address this would be to not even spawn the ingress
// controller if we are running in the context of a third party plugin
if apierrors.IsNotFound(err) {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this changes the behavior of the function, if the namespace doesn't exist it will create it with the apply.ApplyObject. Is that intentional?

@npinaeva npinaeva force-pushed the ingress-controller-apply branch 2 times, most recently from b87efdb to e6248e3 Compare February 9, 2024 10:26
@npinaeva npinaeva changed the title OCPBUGS-28920: Update ingressconfig_controller to use CNO Apply logic OCPBUGS-28920: Update ingressconfig_controller to use field Manager Feb 9, 2024
@openshift-ci-robot
Copy link
Contributor

@npinaeva: This pull request references Jira Issue OCPBUGS-28920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @anuragthehatter

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

In response to this:

Update ingressconfig_controller to use subcontroller "ingress_controller"
for field management on Patch calls. It used to apply changes with
deprecated cluster-network-operator field manager, that was overridden
and removed by ApplyObject. Thus, labels applied to
openshift-host-network namespace were periodically removed.

On upgrade, ingress-owned labels will be merged with "cluster-network-operator/operconfig" Apply call here https://github.com/openshift/cluster-network-operator/blob/master/pkg/apply/apply.go#L139-L150 and removed as the new owner didn't specify them. On the next reconcile loop, ingress controller will re-apply the labels with the new fieldManager and everything should work fine ever after.

For some reason, ingress controller was last this that doesn't use apply logic, but Patches instead.

Should end up with something like this

 managedFields:
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/description: {}
         f:workload.openshift.io/allowed: {}
       f:labels:
         f:policy-group.network.openshift.io/host-network: {}
       f:ownerReferences:
         k:{"uid":"eae5d3b2-cf31-4bfa-940a-fa631adce87d"}: {}
   manager: cluster-network-operator/operconfig
   operation: Apply
   time: "2024-02-07T11:38:45Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:labels:
         f:network.openshift.io/policy-group: {}
         f:policy-group.network.openshift.io/ingress: {}
     f:spec: {}
   manager: cluster-network-operator/ingress_controller
   operation: Apply
   time: "2024-02-07T11:41:11Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/sa.scc.mcs: {}
         f:openshift.io/sa.scc.supplemental-groups: {}
         f:openshift.io/sa.scc.uid-range: {}
   manager: cluster-policy-controller
   operation: Update
   time: "2024-02-07T08:49:53Z"

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.

…ler"

for field management on Patch calls. It used to apply changes with
deprecated cluster-network-operator field manager, that was overridden
and removed by ApplyObject. Thus, labels applied to
openshift-host-network namespace were periodically removed.

Signed-off-by: Nadia Pinaeva <npinaeva@redhat.com>
@kyrtapz
Copy link
Contributor

kyrtapz commented Feb 9, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 9, 2024
Copy link
Contributor

openshift-ci bot commented Feb 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kyrtapz, npinaeva

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 Feb 9, 2024
@kyrtapz
Copy link
Contributor

kyrtapz commented Feb 9, 2024

Overall looks good. We should probably also address the same issue here

We've decided to do a follow up tracked here: https://issues.redhat.com/browse/OCPBUGS-29288

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD d415d80 and 2 for PR HEAD 5231b51 in total

@kyrtapz
Copy link
Contributor

kyrtapz commented Feb 9, 2024

/retest-required

Copy link
Contributor

openshift-ci bot commented Feb 9, 2024

@npinaeva: 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-aws-ovn-single-node 5231b51 link false /test e2e-aws-ovn-single-node
ci/prow/e2e-vsphere-ovn-dualstack-primaryv6 5231b51 link false /test e2e-vsphere-ovn-dualstack-primaryv6
ci/prow/e2e-vsphere-ovn-dualstack 5231b51 link false /test e2e-vsphere-ovn-dualstack
ci/prow/e2e-ovn-ipsec-step-registry 5231b51 link false /test e2e-ovn-ipsec-step-registry
ci/prow/security 5231b51 link false /test security

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

@openshift-merge-bot openshift-merge-bot bot merged commit caa06bb into openshift:master Feb 9, 2024
37 of 42 checks passed
@openshift-ci-robot
Copy link
Contributor

@npinaeva: Jira Issue OCPBUGS-28920: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-28920 has been moved to the MODIFIED state.

In response to this:

Update ingressconfig_controller to use subcontroller "ingress_controller"
for field management on Patch calls. It used to apply changes with
deprecated cluster-network-operator field manager, that was overridden
and removed by ApplyObject. Thus, labels applied to
openshift-host-network namespace were periodically removed.

On upgrade, ingress-owned labels will be merged with "cluster-network-operator/operconfig" Apply call here https://github.com/openshift/cluster-network-operator/blob/master/pkg/apply/apply.go#L139-L150 and removed as the new owner didn't specify them. On the next reconcile loop, ingress controller will re-apply the labels with the new fieldManager and everything should work fine ever after.

For some reason, ingress controller was last this that doesn't use apply logic, but Patches instead.

Should end up with something like this

 managedFields:
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/description: {}
         f:workload.openshift.io/allowed: {}
       f:labels:
         f:policy-group.network.openshift.io/host-network: {}
       f:ownerReferences:
         k:{"uid":"eae5d3b2-cf31-4bfa-940a-fa631adce87d"}: {}
   manager: cluster-network-operator/operconfig
   operation: Apply
   time: "2024-02-07T11:38:45Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:labels:
         f:network.openshift.io/policy-group: {}
         f:policy-group.network.openshift.io/ingress: {}
     f:spec: {}
   manager: cluster-network-operator/ingress_controller
   operation: Apply
   time: "2024-02-07T11:41:11Z"
 - apiVersion: v1
   fieldsType: FieldsV1
   fieldsV1:
     f:metadata:
       f:annotations:
         f:openshift.io/sa.scc.mcs: {}
         f:openshift.io/sa.scc.supplemental-groups: {}
         f:openshift.io/sa.scc.uid-range: {}
   manager: cluster-policy-controller
   operation: Update
   time: "2024-02-07T08:49:53Z"

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-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build cluster-network-operator-container-v4.16.0-202402092208.p0.gcaa06bb.assembly.stream.el9 for distgit cluster-network-operator.
All builds following this will include this PR.

@npinaeva npinaeva deleted the ingress-controller-apply branch February 12, 2024 11:01
@@ -142,5 +142,7 @@ func (r *ReconcileIngressConfigs) updatePolicyGroupLabelOnNamespace(ctx context.

newNamespace.SetLabels(existingLabels)

return r.client.Patch(context.TODO(), newNamespace, crclient.MergeFrom(namespace))
return r.client.Patch(context.TODO(), newNamespace, crclient.MergeFrom(namespace), &crclient.PatchOptions{
Copy link
Member

Choose a reason for hiding this comment

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

@npinaeva @kyrtapz This seems to be using MergePatchType, shouldn't this be changed to use ApplyPatchType for SSA to kick in ?

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/severity-critical Referenced Jira bug's severity is critical for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. 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.

None yet

5 participants