func runSnapshot(config config, tenant string, volume *cephdriver.CephVolume) { now := time.Now() log.Infof("Snapping volume \"%s/%s\" at %v", tenant, volume, now) if err := volume.CreateSnapshot(now.String()); err != nil { log.Errorf("Cannot snap volume: tenant %q, %q: %v", volume, err) } }
func runSnapshotPrune(config config, tenant string, volume *cephdriver.CephVolume) { log.Debugf("starting snapshot prune for %q %v", tenant, volume) list, err := volume.ListSnapshots(100) if err != nil { log.Errorf("Could not list snapshots for tenant %q, volume %v", tenant, volume) return } toDeleteCount := len(list) - int(config[tenant].Snapshot.Keep) if toDeleteCount < 0 { return } for i := 0; i < toDeleteCount; i++ { log.Infof("Removing snapshot %q for tenant %q, volume %v", list[i], tenant, volume) if err := volume.RemoveSnapshot(list[i]); err != nil { log.Errorf("Removing snapshot %q for tenant %q, volume %v failed: %v", list[i], tenant, volume, err) } } }