-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more volume group snapshot in manager
- Loading branch information
Showing
3 changed files
with
95 additions
and
59 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,7 +311,37 @@ func (vg *volumeGroup) ListVolumes(ctx context.Context) ([]types.Volume, error) | |
return vg.volumes, nil | ||
} | ||
|
||
func (vg *volumeGroup) CreateSnapshot(ctx context.Context, name string) (types.VolumeGroupSnapshot, error) { | ||
// TODO: return the VolumeGroupSnapshot | ||
func (vg *volumeGroup) CreateSnapshots(ctx context.Context, name string) ([]types.Snapshot, error) { | ||
group, err := vg.GetName(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ioctx, err := vg.GetIOContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = librbd.GroupSnapCreate(ioctx, group, name) | ||
if err != nil { | ||
if !errors.Is(rados.ErrObjectExists, err) && !strings.Contains(err.Error(), "rbd: ret=-17, File exists") { | ||
return nil, fmt.Errorf("failed to create volume group snapshot %q: %w", name, err) | ||
} | ||
|
||
log.DebugLog(ctx, "ignoring error while creating volume group snapshot %q: %v", vg, err) | ||
} | ||
|
||
info, err := librbd.GroupSnapGetInfo(ioctx, group, name) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get info for volume group snapshot %q: %w", vg.String()+"@"+name, err) | ||
} | ||
|
||
fmt.Printf("volume group snapshot %q has %d snapshots:\n", vg.String()+"@"+name, len(info.Snapshots)) | ||
for _, snap := range info.Snapshots { | ||
// TODO: clone snapshot and create a rbdSnapshot object | ||
// "[email protected]_c35f5de69170_c35fa08d2b61" from {Name:first-volume PoolID:1 SnapID:29} | ||
fmt.Printf(" - %q in pool %d with ID %d\n", snap.Name + "@" + info.Name, snap.PoolID, snap.SnapID) | ||
} | ||
|
||
return nil, nil | ||
} |
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