mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: set scheduling interval on snapshot mirrored image
Mirror-snapshots can also be automatically created on a periodic basis if mirror-snapshot schedules are defined. The mirror-snapshot can be scheduled globally, per-pool, or per-image levels. Multiple mirror-snapshot schedules can be defined at any level. To create a mirror-snapshot schedule with rbd, specify the mirror snapshot schedule add command along with an optional pool or image name; interval; and optional start time: The interval can be specified in days, hours, or minutes using d, h, m suffix respectively. The optional start-time can be specified using the ISO 8601 time format. For example: ``` $ rbd --cluster site-a mirror snapshot schedule add --pool image-pool --image image1 24h 14:00:00-05:00 ``` Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
b1710f4c53
commit
0837c05be0
@ -32,6 +32,7 @@ import (
|
||||
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
librbd "github.com/ceph/go-ceph/rbd"
|
||||
"github.com/ceph/go-ceph/rbd/admin"
|
||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
@ -1733,3 +1734,41 @@ func (rs *rbdSnapshot) isCompatibleThickProvision(dst *rbdVolume) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ri *rbdImage) addSnapshotScheduling(
|
||||
interval admin.Interval,
|
||||
startTime admin.StartTime) error {
|
||||
ls := admin.NewLevelSpec(ri.Pool, ri.RadosNamespace, ri.RbdImageName)
|
||||
ra, err := ri.conn.GetRBDAdmin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
adminConn := ra.MirrorSnashotSchedule()
|
||||
// list all the snapshot scheduling and check at least one image scheduling
|
||||
// exists with specified interval.
|
||||
ssList, err := adminConn.List(ls)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, ss := range ssList {
|
||||
// make sure we are matching image level scheduling. The
|
||||
// `adminConn.List` lists the global level scheduling also.
|
||||
if ss.Name == ri.String() {
|
||||
for _, s := range ss.Schedule {
|
||||
// TODO: Add support to check start time also.
|
||||
// The start time is currently stored with different format
|
||||
// in ceph. Comparison is not possible unless we know in
|
||||
// which format ceph is storing it.
|
||||
if s.Interval == interval {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
err = adminConn.Add(ls, interval, startTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user