-
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
rbd: add backend support for VolumeGroup operations #4719
Merged
mergify
merged 9 commits into
ceph:devel
from
nixpanic:csi-addons/rbd/volumegroup/journal
Jul 24, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a2f86d9
cleanup: make VolumeGroupJournalConnection a private type
nixpanic 013c2a5
rbd: pass CSI-instanceID to CSI-Addons VolumeGroupServer
nixpanic ae76697
rbd: update Volume interface implementation for VolumeGroup APIs
nixpanic 2189d1e
rbd: implement the VolumeGroup interface
nixpanic edde357
rbd: use the Manager to handle CSI-Addons VolumeGroup requests
nixpanic 98c10aa
rbd: add journalledObject as base for VolumeGroup interface
nixpanic 851e052
rbd: remove the VolumeGroup from the journal on DeleteVolumeGroup
nixpanic 33b9aa2
rbd: make VolumeGroup Create/Delete/AddVolume/RemoveVolume idempotent
nixpanic 1825c27
rbd: check if an image is part of a group before adding it
nixpanic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
Copyright 2024 The Ceph-CSI Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package rbd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
librbd "github.com/ceph/go-ceph/rbd" | ||
|
||
"github.com/ceph/ceph-csi/internal/rbd/types" | ||
) | ||
|
||
// AddToGroup adds the image to the group. This is called from the rbd_group | ||
// package. | ||
func (rv *rbdVolume) AddToGroup(ctx context.Context, vg types.VolumeGroup) error { | ||
ioctx, err := vg.GetIOContext(ctx) | ||
Madhu-1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return fmt.Errorf("could not get iocontext for volume group %q: %w", vg, err) | ||
} | ||
|
||
name, err := vg.GetName(ctx) | ||
if err != nil { | ||
return fmt.Errorf("could not get name for volume group %q: %w", vg, err) | ||
} | ||
|
||
// check if the image is already part of a group | ||
// "rbd: ret=-17, File exists" is returned if the image is part of ANY group | ||
image, err := rv.open() | ||
if err != nil { | ||
return fmt.Errorf("failed to open image %q: %w", rv, err) | ||
} | ||
|
||
info, err := image.GetGroup() | ||
if err != nil { | ||
return fmt.Errorf("could not get group information for image %q: %w", rv, err) | ||
} | ||
|
||
if info.Name != "" && info.Name != name { | ||
return fmt.Errorf("image %q is already part of volume group %q", rv, info.Name) | ||
} | ||
|
||
err = librbd.GroupImageAdd(ioctx, name, rv.ioctx, rv.RbdImageName) | ||
if err != nil { | ||
return fmt.Errorf("failed to add image %q to volume group %q: %w", rv, vg, err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// RemoveFromGroup removes the image from the group. This is called from the | ||
// rbd_group package. | ||
func (rv *rbdVolume) RemoveFromGroup(ctx context.Context, vg types.VolumeGroup) error { | ||
ioctx, err := vg.GetIOContext(ctx) | ||
Madhu-1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return fmt.Errorf("could not get iocontext for volume group %q: %w", vg, err) | ||
} | ||
|
||
name, err := vg.GetName(ctx) | ||
if err != nil { | ||
return fmt.Errorf("could not get name for volume group %q: %w", vg, err) | ||
} | ||
|
||
return librbd.GroupImageRemove(ioctx, name, rv.ioctx, rv.RbdImageName) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
rearrange the order here? cephcsi import should come first
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 guideline is not followed everywere. I think and Golang suggests to have imports of local packages at the bottom, that seems to be a coding convention many other Go projects use.
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.
https://github.com/ceph/ceph-csi/blob/devel/docs/coding.md#imports this is one we have, lets stick to it and also update other places if its not followed as followup cleanup?
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.
See #4721. I don't think we should strictly enforce it for existing imports, but it would be nice to use this order in new files.