Skip to content

Conversation

@mkowalski
Copy link

This PR fixes fundamental issue with the previous patch nmstate#1357 that was supposed to introduce strategic merge.

Because we operate on unstructured.Unstructured objects, StrategicMergeFrom was not running correctly as it cannot detect the type of the object. To fix this issue we introduce a conversion to the typed object based on its GroupVersionKind. That way, strategic merge operates on an object with a well-defined type. For any cases where we cannot convert untyped object, we will fallback to the regular merge strategy.

Additionally, we are introducing a function merging metadata for objects type Namespace. This is because those do not have a proper merge strategy defined for their metadata. As a result, strategic merge which involves labels and annotations overrides those as a whole map. Having such a function allows us to properly merge labels and annotations.

This PR fixes fundamental issue with the previous patch nmstate#1357 that was supposed
to introduce strategic merge.

Because we operate on `unstructured.Unstructured` objects, `StrategicMergeFrom`
was not running correctly as it cannot detect the type of the object. To fix
this issue we introduce a conversion to the typed object based on its
GroupVersionKind. That way, strategic merge operates on an object with a
well-defined type. For any cases where we cannot convert untyped object, we will
fallback to the regular merge strategy.

Additionally, we are introducing a function merging metadata for objects type
`Namespace`. This is because those do not have a proper merge strategy defined
for their metadata. As a result, strategic merge which involves labels and
annotations overrides those as a whole map. Having such a function allows us to
properly merge labels and annotations.

Signed-off-by: Mat Kowalski <[email protected]>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 17, 2025
@mkowalski
Copy link
Author

/hold

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Oct 17, 2025
@openshift-ci-robot
Copy link

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

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note text is set and does not match the template
  • dependent bug Jira Issue OCPBUGS-60455 is in the state Verified, which is one of the valid states (MODIFIED, ON_QA, VERIFIED)
  • dependent Jira Issue OCPBUGS-60455 targets the "4.21.0" version, which is one of the valid target versions: 4.21.0
  • bug has dependents

Requesting review from QA contact:
/cc @rbbratta

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

In response to this:

This PR fixes fundamental issue with the previous patch nmstate#1357 that was supposed to introduce strategic merge.

Because we operate on unstructured.Unstructured objects, StrategicMergeFrom was not running correctly as it cannot detect the type of the object. To fix this issue we introduce a conversion to the typed object based on its GroupVersionKind. That way, strategic merge operates on an object with a well-defined type. For any cases where we cannot convert untyped object, we will fallback to the regular merge strategy.

Additionally, we are introducing a function merging metadata for objects type Namespace. This is because those do not have a proper merge strategy defined for their metadata. As a result, strategic merge which involves labels and annotations overrides those as a whole map. Having such a function allows us to properly merge labels and annotations.

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 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 17, 2025
@openshift-ci
Copy link

openshift-ci bot commented Oct 17, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mkowalski

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 Oct 17, 2025
@mkowalski mkowalski changed the title OCPBUGS-60083: Fix strategic merge [4.20] OCPBUGS-60083: Fix strategic merge Oct 17, 2025
@mkowalski
Copy link
Author

/test e2e-operator-ovn-ipv4

@openshift-ci
Copy link

openshift-ci bot commented Oct 17, 2025

@mkowalski: The following test 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-handler-ovn-ipv4 3b7e207 link true /test e2e-handler-ovn-ipv4

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.

@mkowalski
Copy link
Author

/hold

The reason is that this code diverges a lot from what we have on master/4.21; I do not want to merge it unless really necessary. Please keep it open with hold in case there is a critical escalation that is affected by this code.

I do not expect one, but you never know.

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants