Skip to content

🐛 OCPBUGS-76381, OCPBUGS-76383: fix(deploymentConfig): handle empty affinity objects to match OLMv0 erasure behavior#2591

Open
camilamacedo86 wants to merge 1 commit intooperator-framework:mainfrom
camilamacedo86:fix-empty-affinity
Open

🐛 OCPBUGS-76381, OCPBUGS-76383: fix(deploymentConfig): handle empty affinity objects to match OLMv0 erasure behavior#2591
camilamacedo86 wants to merge 1 commit intooperator-framework:mainfrom
camilamacedo86:fix-empty-affinity

Conversation

@camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented Mar 25, 2026

Problem

OLMv1 does not match OLMv0 when users pass empty affinity objects in deploymentConfig.

  1. affinity: {} should erase all affinity from the deployment. OLMv1 keeps the bundle affinity instead.
  2. affinity: {nodeAffinity: {}} should erase only nodeAffinity. OLMv1 leaves an empty nodeAffinity: {} in the manifest.

Solution

Update applyAffinityConfig to follow OLMv0 OverrideDeploymentAffinity behavior:

  • nil → do not touch
  • {} → erase all affinity
  • {nodeAffinity: {}} → erase nodeAffinity, keep others
  • {nodeAffinity: {...}} → replace nodeAffinity, keep others
  • If all sub-fields end up empty, set the whole affinity to nil

Before

# User sets: affinity: {}
# Bundle affinity is kept (wrong)
spec:
  template:
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: disktype
                operator: In
                values:
                - ssd
# User sets: affinity: {nodeAffinity: {}}
# Empty object stays in manifest (wrong)
spec:
  template:
    spec:
      affinity:
        nodeAffinity: {}
        podAffinity: ...

After

# User sets: affinity: {}
# All affinity is erased (correct)
spec:
  template:
    spec:
      # no affinity
# User sets: affinity: {nodeAffinity: {}}
# Only nodeAffinity is erased, podAffinity stays (correct)
spec:
  template:
    spec:
      affinity:
        podAffinity: ...

Copilot AI review requested due to automatic review settings March 25, 2026 08:00
@openshift-ci openshift-ci bot requested review from grokspawn and trgeiger March 25, 2026 08:00
@openshift-ci
Copy link

openshift-ci bot commented Mar 25, 2026

[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 pedjak 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

@netlify
Copy link

netlify bot commented Mar 25, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 934ab7d
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/69c39606063f3600089a2a44
😎 Deploy Preview https://deploy-preview-2591--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@camilamacedo86 camilamacedo86 changed the title 🐛 fix(deploymentConfig): handle empty affinity objects to match OLMv0 erasure behavior 🐛 OCPBUGS-76381, OCPBUGS-76383: fix(deploymentConfig): handle empty affinity objects to match OLMv0 erasure behavior Mar 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the registryv1 bundle deployment rendering logic to match OLMv0’s “erasure” semantics for deploymentConfig.affinity, ensuring that explicitly empty affinity objects clear previously-applied affinity rather than being treated as a no-op.

Changes:

  • Update applyAffinityConfig to treat empty Affinity / empty affinity sub-types (e.g., NodeAffinity: {}) as erase operations.
  • Add/extend unit and e2e coverage for “empty affinity erases” behavior.
  • Add new regression manifest fixtures for empty-affinity rendering cases.

Reviewed changes

Copilot reviewed 26 out of 32 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/operator-controller/rukpak/render/registryv1/generators/generators.go Implement OLMv0-like affinity erasure semantics for empty affinity objects/sub-objects.
internal/operator-controller/rukpak/render/registryv1/generators/generators_test.go Add unit tests covering empty affinity and empty sub-type erasure behavior.
test/e2e/features/install.feature Add e2e scenarios validating that empty affinity config erases previously applied affinity (and sub-type-only erasure).
test/regression/convert/generate-manifests.go Add regression generation cases for empty affinity and empty affinity subtype.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/00_clusterrole_argocd-operator-metrics-reader.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/01_clusterrole_argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/02_clusterrole_argocd-operator.v0.-3gkm3u8zfarktdile5wekso69zs9bgzb988mhjm0y6p.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/03_clusterrolebinding_argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/04_clusterrolebinding_argocd-operator.v0.-3gkm3u8zfarktdile5wekso69zs9bgzb988mhjm0y6p.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/05_configmap_argocd-operator-manager-config.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/06_customresourcedefinition_applications.argoproj.io.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/08_customresourcedefinition_appprojects.argoproj.io.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/09_customresourcedefinition_argocdexports.argoproj.io.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/11_deployment_argocd-operator-controller-manager.yaml New expected output fixture showing affinity erased in rendered Deployment.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/12_service_argocd-operator-controller-manager-metrics-service.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity/13_serviceaccount_argocd-operator-controller-manager.yaml New expected output fixture for empty-affinity rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/00_clusterrole_argocd-operator-metrics-reader.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/01_clusterrole_argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/02_clusterrole_argocd-operator.v0.-3gkm3u8zfarktdile5wekso69zs9bgzb988mhjm0y6p.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/03_clusterrolebinding_argocd-operator.v0-1dhiybrldl1gyksid1dk2dqjsc72psdybc7iyvse5gpx.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/04_clusterrolebinding_argocd-operator.v0.-3gkm3u8zfarktdile5wekso69zs9bgzb988mhjm0y6p.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/05_configmap_argocd-operator-manager-config.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/08_customresourcedefinition_appprojects.argoproj.io.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/09_customresourcedefinition_argocdexports.argoproj.io.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/11_deployment_argocd-operator-controller-manager.yaml New expected output fixture showing nodeAffinity erased while other affinity parts remain.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/12_service_argocd-operator-controller-manager-metrics-service.yaml New expected output fixture for empty-affinity-subtype rendering case.
test/regression/convert/testdata/expected-manifests/argocd-operator.v0.6.0/with-empty-affinity-subtype/13_serviceaccount_argocd-operator-controller-manager.yaml New expected output fixture for empty-affinity-subtype rendering case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants