Skip to content

OADP-7017: fix DPA error when podConfig has no nodeSelector with load…#2125

Open
PrasadJoshi12 wants to merge 1 commit intoopenshift:oadp-devfrom
PrasadJoshi12:OADP-7017-fix-podconfig-nodeaffinity-validation
Open

OADP-7017: fix DPA error when podConfig has no nodeSelector with load…#2125
PrasadJoshi12 wants to merge 1 commit intoopenshift:oadp-devfrom
PrasadJoshi12:OADP-7017-fix-podconfig-nodeaffinity-validation

Conversation

@PrasadJoshi12
Copy link
Contributor

The validator was incorrectly triggering an error whenever podConfig was set (even with only resourceAllocations) alongside nodeAgent.loadAffinity that used matchExpressions. The cross-validation between podConfig and loadAffinityConfig should only run when podConfig.nodeSelector is explicitly set, since that is the only field being compared.

Add a guard of len(PodConfig.NodeSelector) > 0 to the outer condition so that a podConfig containing only resourceAllocations (or other non-selector fields) is valid alongside any loadAffinity configuration.

Made-with: Cursor

Why the changes were made

How to test the changes made

…Affinity

The validator was incorrectly triggering an error whenever podConfig was
set (even with only resourceAllocations) alongside nodeAgent.loadAffinity
that used matchExpressions. The cross-validation between podConfig and
loadAffinityConfig should only run when podConfig.nodeSelector is
explicitly set, since that is the only field being compared.

Add a guard of len(PodConfig.NodeSelector) > 0 to the outer condition so
that a podConfig containing only resourceAllocations (or other non-selector
fields) is valid alongside any loadAffinity configuration.

Made-with: Cursor
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05f2dfbf-a320-4b43-8607-7de3da16ab17

📥 Commits

Reviewing files that changed from the base of the PR and between f08beb2 and 8c4c85a.

📒 Files selected for processing (2)
  • internal/controller/validator.go
  • internal/controller/validator_test.go

Walkthrough

The validation logic in the data protection validator was adjusted to only perform selector consistency checks between podConfig and loadAffinityConfig when podConfig explicitly defines a nodeSelector. A corresponding test case was added to verify validation succeeds when podConfig contains only resource allocations without nodeSelector.

Changes

Cohort / File(s) Summary
Validator Logic & Tests
internal/controller/validator.go, internal/controller/validator_test.go
Added conditional check to run validation only when podConfig.nodeSelector is non-empty; added test case verifying validation passes when podConfig contains only resource allocations alongside loadAffinityConfig with nodeSelector.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 19, 2026

@PrasadJoshi12: This pull request references OADP-7017 which is a valid jira issue.

Details

In response to this:

The validator was incorrectly triggering an error whenever podConfig was set (even with only resourceAllocations) alongside nodeAgent.loadAffinity that used matchExpressions. The cross-validation between podConfig and loadAffinityConfig should only run when podConfig.nodeSelector is explicitly set, since that is the only field being compared.

Add a guard of len(PodConfig.NodeSelector) > 0 to the outer condition so that a podConfig containing only resourceAllocations (or other non-selector fields) is valid alongside any loadAffinity configuration.

Made-with: Cursor

Why the changes were made

How to test the changes made

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 openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 19, 2026
@PrasadJoshi12
Copy link
Contributor Author

Verified

$ oc get dpa -o yaml ts-dpa
apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionApplication
metadata:
  creationTimestamp: "2026-03-19T10:30:13Z"
  generation: 1
  name: ts-dpa
  namespace: openshift-adp
  resourceVersion: "75056"
  uid: ca10eef0-4292-4ecd-844e-e9bc9e0be451
spec:
  backupLocations:
  - velero:
      credential:
        key: cloud
        name: cloud-credentials-gcp
      default: true
      objectStorage:
        bucket: oadp5071ts6tp
        prefix: velero-e2e-ac45e82c-c451-11f0-83df-5ea249a46219
      provider: gcp
  configuration:
    nodeAgent:
      enable: true
      loadAffinity:
      - nodeSelector:
          matchExpressions:
          - key: foo
            operator: In
            values:
            - bar
      podConfig:
        resourceAllocations: {}
      uploaderType: kopia
    velero:
      defaultPlugins:
      - openshift
      - gcp
      - csi
      disableFsBackup: false
  logFormat: text
status:
  conditions:
  - lastTransitionTime: "2026-03-19T10:30:54Z"
    message: Reconcile complete
    reason: Complete
    status: "True"
    type: Reconciled
  - lastTransitionTime: "2026-03-19T10:31:16Z"
    message: 'Velero deployment ready: 1/1 replicas'
    reason: DeploymentReady
    status: "True"
    type: VeleroReady
  - lastTransitionTime: "2026-03-19T10:30:54Z"
    message: 'NodeAgent DaemonSet ready: 0/0 pods ready'
    reason: DaemonSetReady
    status: "True"
    type: NodeAgentReady
  - lastTransitionTime: "2026-03-19T10:30:13Z"
    message: Non-Admin controller is disabled
    reason: ComponentDisabled
    status: "True"
    type: NonAdminReady
  - lastTransitionTime: "2026-03-19T10:30:13Z"
    message: VM File Restore controller is disabled
    reason: ComponentDisabled
    status: "True"
    type: VMFileRestoreReady
  - lastTransitionTime: "2026-03-19T10:30:13Z"
    message: KubeVirt DataMover controller is disabled
    reason: ComponentDisabled
    status: "True"
    type: KubevirtDatamoverReady

@openshift-ci
Copy link

openshift-ci bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: PrasadJoshi12, sseago

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

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 19, 2026
@openshift-ci
Copy link

openshift-ci bot commented Mar 24, 2026

@PrasadJoshi12: 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.

@weshayutin
Copy link
Contributor

@kaovilai please have a look

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants