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

[WIP] Implement support for volume group mirroring #4739

Draft
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

Madhu-1
Copy link
Collaborator

@Madhu-1 Madhu-1 commented Jul 29, 2024

This PR does the required changes so that the volume group can also implement the Mirror interface and we do need to make many changes in the replication code to work differently for the mirroring of an image or a mirroring of a group.

Note:- The last commit to add use go-ceph is commented out, please don't review it, Will remove that code and make changes to the mirror implementation of the group. except that other commits can be reviewed.

Depends-on: ceph/go-ceph#1010

@Madhu-1 Madhu-1 force-pushed the implement-rbd-vg-mirror branch 7 times, most recently from bd794c1 to 4a5761c Compare July 30, 2024 11:53
internal/rbd/manager.go Outdated Show resolved Hide resolved
internal/rbd/manager.go Outdated Show resolved Hide resolved
internal/csi-addons/rbd/volumegroup.go Outdated Show resolved Hide resolved
internal/csi-addons/rbd/volumegroup.go Outdated Show resolved Hide resolved
internal/csi-addons/rbd/volumegroup.go Outdated Show resolved Hide resolved
internal/csi-addons/rbd/replication.go Outdated Show resolved Hide resolved
internal/rbd/group/volume_group.go Outdated Show resolved Hide resolved

// GroupStatus is a wrapper around librbd.MirrorGroupInfo that contains the
// group mirror info.
type GroupStatus struct {
Copy link
Member

Choose a reason for hiding this comment

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

why not just do it like

type GroupStatus *librbd.MirrorGroupInfo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Methods defined on the original type are not available to the new type unless you explicitly defined

if we create a type i need to implement duplication methods of MirrorGroupInfo here which is again not much useful, lets keep it this way which allow us to use methods of librbd struct without any problem

Copy link
Contributor

mergify bot commented Jul 30, 2024

This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏

@Madhu-1 Madhu-1 force-pushed the implement-rbd-vg-mirror branch 3 times, most recently from 3337a23 to add2d0b Compare August 1, 2024 05:00
@Madhu-1
Copy link
Collaborator Author

Madhu-1 commented Aug 1, 2024

@nixpanic This is ready for one more round of review :)

Copy link
Contributor

mergify bot commented Aug 1, 2024

This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏


// GetMirrorSource returns the source of the mirror for the given volume or group.
GetMirrorSource(ctx context.Context, volumeID string,
rep *replication.ReplicationSource) ([]Volume, Mirror, error)
Copy link
Member

Choose a reason for hiding this comment

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

it is not clear to me why []Volume is returned. Should that not be either a single Volume or a VolumeGroup?

Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to have a Mirror.GetSource() function so that the API is easier to understand?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's put everything related to processing volumes within functions in mirror type ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

would it make sense to have a Mirror.GetSource() function so that the API is easier to understand?

@nixpanic I put it with the Manager because that is the one who is generating the volume and group from an ID, moving this to Mirroring

it is not clear to me why []Volume is returned. Should that not be either a single Volume or a VolumeGroup?

This is required because we need to work on all the volumes if its a group, i am trying to avoid type casting and doing the ListVolumes and generating the volumes again that contains the connections, let me know if you have any suggestions

Let's put everything related to processing volumes within functions in mirror type ?

I mostly added all the mirroring specific things to mirror type but there are again generic one as well that the reason i left it in volume type as it makes more sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍
We can check on volumes and refactor it later on.
Everything LGTM
Only concern now is ceph's API stability and go-ceph pr going in.

ceph/go-ceph#1010 (comment)
ceph/ceph#53793 (comment)

@@ -469,3 +474,296 @@ func (vg *volumeGroup) ListVolumes(ctx context.Context) ([]types.Volume, error)
func (vg *volumeGroup) ToMirror() (types.Mirror, error) {
return vg, nil
}

func (vg *volumeGroup) EnableMirroring(ctx context.Context, mode librbd.ImageMirrorMode) error {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it is worth to simplify things a little by placing this in a separate file group_mirror.go?

type volumeGroupMirror *volumeGroup // or make it a struct with extra members?

func (vgm *volumeGroupMirror) EnableMirroring(ctx context.Context, mode librbd.ImageMirrorMode) error {
    ...

This would keep the VolumeGroup interface smal(ler). I am considering a similar approach for VolumeGroupSnapshot.

return nil, fmt.Errorf("failed to get volume group mirroring info %q: %w", vg, err)
}

return GroupInfo{MirrorGroupInfo: info}, nil
Copy link
Member

Choose a reason for hiding this comment

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

you could also do

type GroupInfo *librbd.MirrorGroupInfo

and cast it here

return GroupInfo(info)

That looks a little simpler to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes but again this will have problem like #4739 (comment) and adding new field to GroupInfo need more refractoring, IMO this should be okay but the struct name should not be exported(taken care of it)

}

func (status GlobalMirrorGroupStatus) GetState() string {
return status.GlobalMirrorGroupStatus.Info.State.String()
Copy link
Member

Choose a reason for hiding this comment

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

could any of the members be nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not possible as the members are not pointers


// GroupInfo is a wrapper around librbd.MirrorGroupInfo that contains the
// group mirror info.
type GroupInfo struct {
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 use a struct, consider exposing an interface instead of the struct. That encourages a cleaner API towards consumers.

@@ -280,15 +280,12 @@ func (rs *ReplicationServer) EnableVolumeReplication(ctx context.Context,
mgr := rbd.NewManager(rs.csiID, req.GetParameters(), req.GetSecrets())
defer mgr.Destroy(ctx)

rbdVol, err := mgr.GetVolumeByID(ctx, volumeID)
volumes, mirror, err := mgr.GetMirrorSource(ctx, volumeID, req.GetReplicationSource())
Copy link
Contributor

Choose a reason for hiding this comment

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

let's call volumeID something else like reqID or replicationID.
It can then be either referring to a single volume or group (or later on snapshot).

This adds the required functionality to
call the go-ceph API's for the rbd
volume group.

Signed-off-by: Madhu Rajanna <[email protected]>
internal/rbd/manager.go Outdated Show resolved Hide resolved
implementing GetMirrorSource in manager
to return volume or the volumegroup based
on the replication source, if replication
source is nil return the volume details
for backward compatibility.

Signed-off-by: Madhu Rajanna <[email protected]>
This is temporary test only
commit and good suitable for
review.

Signed-off-by: Madhu Rajanna <[email protected]>
Copy link
Contributor

mergify bot commented Aug 9, 2024

The PR description contains the unsupported [skip ci] command, please update the description and mark the PR ready for review again.

Copy link
Contributor

mergify bot commented Aug 15, 2024

This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏

Copy link

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 Sep 14, 2024
@Madhu-1 Madhu-1 removed the stale label Sep 16, 2024
Copy link

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 Oct 16, 2024
@Madhu-1 Madhu-1 added keepalive This label can be used to disable stale bot activiity in the repo and removed stale labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keepalive This label can be used to disable stale bot activiity in the repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants