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

cleanup: migration of volrep to csi-addons #3608

Merged
merged 1 commit into from
Apr 21, 2023
Merged

cleanup: migration of volrep to csi-addons #3608

merged 1 commit into from
Apr 21, 2023

Conversation

riya-singhal31
Copy link
Contributor

@riya-singhal31 riya-singhal31 commented Jan 12, 2023

This commit moves the volrep logic(replication controller server) from internal/rbd to internal/csi-addons/rbd.

Signed-off-by: riya-singhal31 rsinghal@redhat.com

@mergify mergify bot added the cleanup label Jan 12, 2023
@riya-singhal31
Copy link
Contributor Author

Addresses task item 1 for - #3314

@riya-singhal31 riya-singhal31 marked this pull request as draft January 12, 2023 10:13
@riya-singhal31 riya-singhal31 changed the title cleanup: migration of volrep to csi-addons [WIP]cleanup: migration of volrep to csi-addons Jan 12, 2023
@nixpanic nixpanic self-requested a review January 18, 2023 09:07
@riya-singhal31 riya-singhal31 changed the title [WIP]cleanup: migration of volrep to csi-addons cleanup: migration of volrep to csi-addons Feb 1, 2023
@riya-singhal31 riya-singhal31 marked this pull request as ready for review February 1, 2023 08:50
@yati1998
Copy link
Contributor

yati1998 commented Feb 1, 2023

@riya-singhal31 please update the PR description, removing the default text.

@nixpanic nixpanic requested a review from a team February 1, 2023 09:01
@@ -26,6 +26,7 @@ import (
"strings"
"time"

rbdutil "github.com/ceph/ceph-csi/internal/rbd"
Copy link
Collaborator

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 {
Copy link
Collaborator

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,
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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

Copy link
Contributor Author

@riya-singhal31 riya-singhal31 Feb 1, 2023

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

Copy link
Contributor Author

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.

@@ -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"

Copy link
Collaborator

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

@@ -0,0 +1,133 @@
/*
Copyright 2021 The Ceph-CSI Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

2023?

Copy link
Member

@nixpanic nixpanic left a 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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)

"google.golang.org/grpc/status"
)

func ResyncVol(localStatus librbd.SiteMirrorImageStatus, rbdVol *rbdVolume, force bool) error {
Copy link
Member

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.

Copy link
Member

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?

Copy link
Contributor Author

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"
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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"
Copy link
Member

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.

"google.golang.org/grpc/status"
)

func ResyncVol(localStatus librbd.SiteMirrorImageStatus, rbdVol *rbdVolume, force bool) error {
Copy link
Member

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"
Copy link
Member

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.

@Madhu-1
Copy link
Collaborator

Madhu-1 commented Feb 3, 2023

@riya-singhal31 I Hope you have done e2e testing for volumeReplication as we dont have CI testing for this one.

@github-actions
Copy link

github-actions bot commented Mar 5, 2023

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.

@github-actions github-actions bot added the stale label Mar 5, 2023
@riya-singhal31
Copy link
Contributor Author

Up to avoid stale.

@github-actions github-actions bot removed the stale label Mar 17, 2023
@riya-singhal31
Copy link
Contributor Author

@riya-singhal31 I Hope you have done e2e testing for volumeReplication as we dont have CI testing for this one.

Yes, that is done.

Copy link
Collaborator

@Madhu-1 Madhu-1 left a 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

Copy link
Collaborator

@Madhu-1 Madhu-1 left a comment

Choose a reason for hiding this comment

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

@riya-singhal31
Copy link
Contributor Author

LGTM, https://github.com/ceph/ceph-csi/pull/3608/files#r1092953730, still waiting for the response

cc @nixpanic

@nixpanic
Copy link
Member

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Apr 20, 2023

rebase

✅ Branch has been successfully rebased

Copy link
Contributor

@yati1998 yati1998 left a comment

Choose a reason for hiding this comment

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

LGTM

@nixpanic
Copy link
Member

@Mergifyio rebase

This commit moves the volrep logic from internal/rbd to
internal/csi-addons/rbd.

Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
@mergify
Copy link
Contributor

mergify bot commented Apr 21, 2023

rebase

✅ Branch has been successfully rebased

@nixpanic nixpanic added the ok-to-test Label to trigger E2E tests label Apr 21, 2023
@github-actions
Copy link

/test ci/centos/k8s-e2e-external-storage/1.24

@github-actions
Copy link

/test ci/centos/k8s-e2e-external-storage/1.25

@github-actions
Copy link

/test ci/centos/k8s-e2e-external-storage/1.26

@github-actions
Copy link

/test ci/centos/k8s-e2e-external-storage/1.27

@github-actions
Copy link

/test ci/centos/mini-e2e-helm/k8s-1.24

@github-actions
Copy link

/test ci/centos/mini-e2e-helm/k8s-1.25

@github-actions
Copy link

/test ci/centos/mini-e2e-helm/k8s-1.26

@github-actions
Copy link

/test ci/centos/mini-e2e-helm/k8s-1.27

@github-actions
Copy link

/test ci/centos/mini-e2e/k8s-1.24

@github-actions
Copy link

/test ci/centos/mini-e2e/k8s-1.25

@github-actions
Copy link

/test ci/centos/mini-e2e/k8s-1.26

@github-actions
Copy link

/test ci/centos/mini-e2e/k8s-1.27

@github-actions
Copy link

/test ci/centos/upgrade-tests-cephfs

@github-actions
Copy link

/test ci/centos/upgrade-tests-rbd

@github-actions github-actions bot removed the ok-to-test Label to trigger E2E tests label Apr 21, 2023
@mergify mergify bot merged commit 304194a into ceph:devel Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants