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

create RS irrespective of PV mount status. #1724

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

pruthvitd
Copy link
Member

@pruthvitd pruthvitd commented Dec 12, 2024

Fix for [2319824] [RDR] Replication via Volsync requires PVC to be mounted before PVC is synchronized
* Create ReplicationSource irrespective of PV being mounted to running pod.
* Renamed "validatePVCBeforeRS" as "validatePVCForFinalSync"

@pruthvitd
Copy link
Member Author

How this is tested:

(ramen) [root@ramen1 samples]# kubectl scale deployment/busybox --replicas=0 -n deployment-cephfs --context dr1
deployment.apps/busybox scaled
(ramen) [root@ramen1 samples]# kubectl get replicationsource -A --context dr1
NAMESPACE           NAME          SOURCE        LAST SYNC              DURATION        NEXT SYNC
deployment-cephfs   busybox-pvc   busybox-pvc   2024-12-12T16:54:40Z   40.696555939s   2024-12-12T16:55:00Z
(ramen) [root@ramen1 samples]# kubectl delete replicationsource busybox-pvc -n deployment-cephfs  --context dr1
replicationsource.volsync.backube "busybox-pvc" deleted
(ramen) [root@ramen1 samples]# kubectl get po -n deployment-cephfs --context dr1
NAME                                      READY   STATUS    RESTARTS   AGE
volsync-rsync-tls-src-busybox-pvc-5kb8n   0/1     Pending   0          1s
(ramen) [root@ramen1 samples]# kubectl get po -n deployment-cephfs --context dr1
No resources found in deployment-cephfs namespace.
(ramen) [root@ramen1 samples]# kubectl get replicationsource -A --context dr1
NAMESPACE           NAME          SOURCE        LAST SYNC              DURATION        NEXT SYNC
deployment-cephfs   busybox-pvc   busybox-pvc   2024-12-12T16:57:34Z   34.517990544s   2024-12-12T16:58:00Z

ramen-dr-cluster-operator pod log:

[1] 588806
(ramen) [root@ramen1 ramen]# grep "PVC is not in use by ready pod, yet creating RS ..." /root/DR/samples/dr1-ramen.log
2024-12-12T16:55:11.923Z	INFO	controllers.VolumeReplicationGroup	volsync/vshandler.go:399	PVC is not in use by ready pod, yet creating RS ...	{"VolumeReplicationGroup": {"name":"deployment-cephfs-drpc","namespace":"deployment-cephfs"}, "rid": "14afb717-e7a4-4367-a85c-b31b207693a6", "rsSpec": {"protectedPVC":{"namespace":"deployment-cephfs","name":"busybox-pvc","protectedByVolSync":true,"storageID":{"id":""},"replicationID":{"id":""},"storageClassName":"rook-cephfs","annotations":{"apps.open-cluster-management.io/hosting-subscription":"deployment-cephfs/subscription","apps.open-cluster-management.io/reconcile-option":"merge"},"labels":{"app":"deployment-cephfs","app.kubernetes.io/part-of":"deployment-cephfs","appname":"busybox"},"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"1Gi"}},"conditions":[{"type":"ReplicationSourceSetup","status":"True","observedGeneration":1,"lastTransitionTime":"2024-12-12T16:37:47Z","reason":"SourceInitialized","message":"Ready"}],"volumeMode":"Filesystem"}}, "runFinalSync": false}

return false, nil
l.Info("PVC is not in use by ready pod, yet creating RS ...")
} else {
l.Info("PVC is use by ready pod, proceeding to create RS ...")
}
Copy link
Member

Choose a reason for hiding this comment

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

I would use same log, just change the part describing the pvc:

PVC is use by ready pod, proceeding to create RS"
PVC is not used by ready pod, proceeding to create RS"

The "..." part is not helpful, so you can remove it while changing the logs. It can also be done in a preparation commit to keep one logic change for every commit.

Since we don't skip if inUseByReadyPod is false, we can use more natual check:

if inUseByReadyPod {
    log for used pvc...
} else {
    log for unused pvc ...
}

Copy link
Member

Choose a reason for hiding this comment

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

I would just replace all lines from line 370 to 399 and replace it with this:

_, err := v.getRS(getReplicationSourceName(rsSpec.ProtectedPVC.Name), rsSpec.ProtectedPVC.Namespace)
if err != nil {
    if !kerrors.IsNotFound(err) {
        return false, err
    }
}

return true, nil

@pruthvitd pruthvitd force-pushed the dfbug-580 branch 2 times, most recently from d18d555 to 841d754 Compare December 16, 2024 17:55
if err != nil {
// Err looking up the RS, return it
return false, err
l.Info("ReplicationSource does not exist, creating it now. ")
Copy link
Member

Choose a reason for hiding this comment

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

If you want to log here, just say "ReplicationSource does not exist". If you say "creating it now" it implies that this function will create it. But this function does do that. So I would ignore that part.

@pruthvitd pruthvitd force-pushed the dfbug-580 branch 2 times, most recently from 4412732 to b206162 Compare December 17, 2024 04:52
Copy link
Member

@ELENAGER ELENAGER left a comment

Choose a reason for hiding this comment

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

LGTM

return true, nil
l.Info("Good to proceed with final sync.")

return true, nil // Good to proceed - PVC is not in use, not mounted to node (or does not exist-should not happen)
Copy link
Member

Choose a reason for hiding this comment

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

The last thing is to remove this comment

	Fix for [[2319824] [RDR] Replication via Volsync requires PVC to be mounted before PVC is synchronized](https://issues.redhat.com/browse/DFBUGS-580)
	* Create ReplicationSource irrespective of PV being mounted to
running pod.
        * Renamed "validatePVCBeforeRS" as "validatePVCForFinalSync"

Signed-off-by: pruthvitd <[email protected]>

create RS irrespective of PV mount status.
	Fix for [[2319824] [RDR] Replication via Volsync requires PVC to be mounted before PVC is synchronized](https://issues.redhat.com/browse/DFBUGS-580)
	Create ReplicationSource irrespective of PV being mounted to
running pod.

Signed-off-by: pruthvitd <[email protected]>
Copy link
Member

@BenamarMk BenamarMk left a comment

Choose a reason for hiding this comment

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

LGTM.
Thanks @pruthvitd

@BenamarMk BenamarMk merged commit a896bb1 into RamenDR:main Dec 18, 2024
23 checks passed
@pruthvitd pruthvitd deleted the dfbug-580 branch December 18, 2024 16:41
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.

5 participants