Bug 2122954

Summary: Validation of DRPolicy without any DRClusters passess
Product: [Red Hat Storage] Red Hat OpenShift Data Foundation Reporter: Martin Bukatovic <mbukatov>
Component: odf-drAssignee: rakesh <rgowdege>
odf-dr sub component: ramen QA Contact: Shrivaibavi Raghaventhiran <sraghave>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: low    
Priority: unspecified CC: bmekhiss, ebenahar, hnallurv, muagarwa, ocs-bugs, odf-bz-bot, rgowdege, srangana
Version: 4.11   
Target Milestone: ---   
Target Release: ODF 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.12.0-152 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-02-08 14:06:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Bukatovic 2022-08-31 12:25:58 UTC
Description of problem
======================

Validation of DRPolicy without any DRClusters passess, but it would make more
sense if it failed, so that the validation is aligned with ODF DR web UI, which
doesn't allow one to create such empty policy.

Version-Release number of selected component
============================================

OCP:
- c1: 4.11.0-0.nightly-2022-08-19-151011
- c2: 4.11.0-0.nightly-2022-08-19-091806
- hub 4.11.0-0.nightly-2022-08-19-151011

ACM 2.5.1
ODF 4.11.0-137 (4.11 GA)

How reproducible
================

100%

Steps to Reproduce
==================

1. Deploy and configure clusters for Metro DR.
2. Create DRPolicy "testing-policy" with 2 clusters (if you alreay have a valid
   DRPolicy created, you can reuse the clusters which are part of it).
3. Edit DRPolicy "testing-policy" and drop both DR Clusters from the spec.
4. Check DRPolicy validation status.

Actual results
==============

Validation DRPolicy/testing-policy without any DR Clusters passess:

```
$ oc get DRPolicy/testing-policy -o yaml
apiVersion: ramendr.openshift.io/v1alpha1
kind: DRPolicy
metadata:
  creationTimestamp: "2022-08-31T12:08:01Z"
  finalizers:
  - drpolicies.ramendr.openshift.io/ramen
  generation: 4
  labels:
    cluster.open-cluster-management.io/backup: resource
    ocsqe: "2022-08-31"
  name: testing-policy
  resourceVersion: "22523313"
  uid: 0d005ac8-118c-4fd8-a338-1e6668cda5f6
spec:
  replicationClassSelector: {}
  schedulingInterval: 0m
  volumeSnapshotClassSelector: {}
status:
  conditions:
  - lastTransitionTime: "2022-08-31T12:12:51Z"
    message: drpolicy validated
    observedGeneration: 4
    reason: Succeeded
    status: "True"
    type: Validated
```

Expected results
================

Validation of an empty DRPolicy fails.

Comment 4 Shrivaibavi Raghaventhiran 2022-12-19 12:25:59 UTC
@rgowdege Can you please add the Fixed in version ?

Comment 16 Shrivaibavi Raghaventhiran 2023-01-09 17:13:25 UTC
Version:
--------
OCP - 4.12.0-0.nightly-2023-01-04-203333
ODF - quay.io/rhceph-dev/ocs-registry:4.12.0-156
ACM - 2.7

Test:
-----
* Removed drcluster list from drpolicy and DRpolicy validation failed as expected. hence moving this to verified

$ oc get drpolicy -o yaml
apiVersion: v1
items:
- apiVersion: ramendr.openshift.io/v1alpha1
  kind: DRPolicy
  metadata:
    creationTimestamp: "2023-01-09T13:44:56Z"
    finalizers:
    - drpolicies.ramendr.openshift.io/ramen
    generation: 3
    labels:
      cluster.open-cluster-management.io/backup: resource
    name: ocpcluster1-ocpcluster2
    resourceVersion: "6375963"
    uid: 5b8c8f24-56a1-4ae0-9313-c82e577e09bf
  spec:
    drClusters: []
    replicationClassSelector: {}
    schedulingInterval: 0m
    volumeSnapshotClassSelector: {}
  status:
    conditions:
    - lastTransitionTime: "2023-01-09T16:53:22Z"
      message: missing DRClusters list in policy
      observedGeneration: 3
      reason: ValidationFailed
      status: "False"
      type: Validated
kind: List
metadata: