-
Notifications
You must be signed in to change notification settings - Fork 547
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
cleanup: migration of volrep to csi-addons #3608
Conversation
Addresses task item 1 for - #3314 |
@riya-singhal31 please update the PR description, removing the default text. |
@@ -26,6 +26,7 @@ import ( | |||
"strings" | |||
"time" | |||
|
|||
rbdutil "github.com/ceph/ceph-csi/internal/rbd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of rbdutil
call it as corerbd
?
@@ -840,29 +794,6 @@ func getLastSyncTime(description string) (*timestamppb.Timestamp, error) { | |||
return lastSyncTime, nil | |||
} | |||
|
|||
func resyncVolume(localStatus librbd.SiteMirrorImageStatus, rbdVol *rbdVolume, force bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal function no need to move to internal/rbd
default: | ||
return nil, status.Errorf(codes.InvalidArgument, "image is in %s Mode", mirroringInfo.State) | ||
} | ||
|
||
return &replication.DisableVolumeReplicationResponse{}, nil | ||
} | ||
|
||
func disableVolumeReplication(rbdVol *rbdVolume, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal function no need to move to internal/rbd
|
||
// resyncRequired returns true if local image is in split-brain state and image | ||
// needs resync. | ||
func resyncRequired(localStatus librbd.SiteMirrorImageStatus) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal function no need to move to internal/rbd
} | ||
|
||
// repairResyncedImageID updates the existing image ID with new one. | ||
func repairResyncedImageID(ctx context.Context, rv *rbdVolume, ready bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal function no need to move to internal/rbd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Madhu, reason for doing this was I'll have to export this rbdVolume parameter then, so to prevent this variable from exporting moved it.
So should we go with exporting rbdVolume? @Madhu-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of exporting the variable, I exported the function.
internal/rbd/driver/driver.go
Outdated
@@ -24,6 +24,7 @@ import ( | |||
casrbd "github.com/ceph/ceph-csi/internal/csi-addons/rbd" | |||
csiaddons "github.com/ceph/ceph-csi/internal/csi-addons/server" | |||
csicommon "github.com/ceph/ceph-csi/internal/csi-common" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a new line here as both are internal packages
internal/rbd/replication.go
Outdated
@@ -0,0 +1,133 @@ | |||
/* | |||
Copyright 2021 The Ceph-CSI Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2023?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a little more cleanup would be nice, this is already a great start!
@@ -325,61 +326,14 @@ func (rs *ReplicationServer) DisableVolumeReplication(ctx context.Context, | |||
case librbd.MirrorImageDisabling: | |||
return nil, status.Errorf(codes.Aborted, "%s is in disabling state", volumeID) | |||
case librbd.MirrorImageEnabled: | |||
return disableVolumeReplication(rbdVol, mirroringInfo, force) | |||
return rbdutil.DisableVolumeReplication(rbdVol, mirroringInfo, force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rbdutil
functions should not return a GRPC response. Only the packages under internal/csi-addons/
should use the CSI-Addons GRPC structures/functions.
Maybe DisableVolumeReplication()
can return an error instead, which can then be used to construct a DisableVolumeReplicationResponse
reply here?
@@ -671,7 +625,7 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context, | |||
ready = checkRemoteSiteStatus(ctx, mirrorStatus) | |||
} | |||
|
|||
err = resyncVolume(localStatus, rbdVol, req.Force) | |||
err = rbdutil.ResyncVol(localStatus, rbdVol, req.Force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe make this a function of rbdVol
so that you can call is like
err = rbdVol.ResyncVolume(localStatus, req.Force)
@@ -683,7 +637,7 @@ func (rs *ReplicationServer) ResyncVolume(ctx context.Context, | |||
return nil, status.Error(codes.Internal, err.Error()) | |||
} | |||
|
|||
err = repairResyncedImageID(ctx, rbdVol, ready) | |||
err = rbdutil.RepairResyncedImageID(ctx, rbdVol, ready) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, it would be cleaner to have RepairResyncedImageID
a function of rbdVol
so you can do
err = rbdVol.RepairResyncedImageID(ctx, ready)
internal/rbd/replication.go
Outdated
"google.golang.org/grpc/status" | ||
) | ||
|
||
func ResyncVol(localStatus librbd.SiteMirrorImageStatus, rbdVol *rbdVolume, force bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a great opportunity to cleanup even more. These functions should all be part of the rbdVolume
object, so make them look like
func (ri *rbdVolume) ResyncVol(localStatus librbd.SiteMirrorImageStatus, force bool) error {
These changes can be a 2nd commit in the same PR if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still open, could you let me know what you want to do with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Niels for the review. Yes, addressing all these changes as a part of 2nd commit. So they are not present in this commit.
"strings" | ||
|
||
librbd "github.com/ceph/go-ceph/rbd" | ||
"github.com/csi-addons/spec/lib/go/replication" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
csi-addons and grpc packages should not be imported. Where used, return an error on failure instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still something that needs to be addressed. The cleanup is important so that internal/rbd
does not use CSI-Addons functions/structs anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take this in a separate PR, @nixpanic, will that be fine?
@@ -26,6 +26,7 @@ import ( | |||
"strings" | |||
"time" | |||
|
|||
corerbd "github.com/ceph/ceph-csi/internal/rbd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit, the filename could be just replication.go
as all the files in the directory are CSI-Addons controllers.
internal/rbd/replication.go
Outdated
"google.golang.org/grpc/status" | ||
) | ||
|
||
func ResyncVol(localStatus librbd.SiteMirrorImageStatus, rbdVol *rbdVolume, force bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still open, could you let me know what you want to do with it?
"strings" | ||
|
||
librbd "github.com/ceph/go-ceph/rbd" | ||
"github.com/csi-addons/spec/lib/go/replication" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still something that needs to be addressed. The cleanup is important so that internal/rbd
does not use CSI-Addons functions/structs anymore.
@riya-singhal31 I Hope you have done e2e testing for volumeReplication as we dont have CI testing for this one. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in two weeks if no further activity occurs. Thank you for your contributions. |
Up to avoid stale. |
Yes, that is done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the CI problem. The build itself is not passing. Please make sure it's tested once you make the required changes to make CI green
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, https://github.com/ceph/ceph-csi/pull/3608/files#r1092953730, still waiting for the response
cc @nixpanic |
@Mergifyio rebase |
✅ Branch has been successfully rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Mergifyio rebase |
This commit moves the volrep logic from internal/rbd to internal/csi-addons/rbd. Signed-off-by: riya-singhal31 <[email protected]>
✅ Branch has been successfully rebased |
/test ci/centos/k8s-e2e-external-storage/1.24 |
/test ci/centos/k8s-e2e-external-storage/1.25 |
/test ci/centos/k8s-e2e-external-storage/1.26 |
/test ci/centos/k8s-e2e-external-storage/1.27 |
/test ci/centos/mini-e2e-helm/k8s-1.24 |
/test ci/centos/mini-e2e-helm/k8s-1.25 |
/test ci/centos/mini-e2e-helm/k8s-1.26 |
/test ci/centos/mini-e2e-helm/k8s-1.27 |
/test ci/centos/mini-e2e/k8s-1.24 |
/test ci/centos/mini-e2e/k8s-1.25 |
/test ci/centos/mini-e2e/k8s-1.26 |
/test ci/centos/mini-e2e/k8s-1.27 |
/test ci/centos/upgrade-tests-cephfs |
/test ci/centos/upgrade-tests-rbd |
This commit moves the volrep logic(replication controller server) from internal/rbd to internal/csi-addons/rbd.
Signed-off-by: riya-singhal31 [email protected]