v2 #2

Merged
shoopea merged 29 commits from v2 into master 2023-08-21 20:03:11 +02:00
Showing only changes of commit 7e8a34a435 - Show all commits

30
app.go
View File

@ -169,7 +169,12 @@ func (a *App) Cleanup(now time.Time) error {
for _, dest := range a.destinations { for _, dest := range a.destinations {
dest = dest.Append("/" + src.Box() + "/" + src.Path()) dest = dest.Append("/" + src.Box() + "/" + src.Path())
for _, s := range cfg.box[dest.Box()].zfs.filesystems[dest.Path()].snapshots { for _, s := range cfg.box[dest.Box()].zfs.filesystems[dest.Path()].snapshots {
if expired, err := s.Expired(now); err != nil { if !s.Valid() {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
} else if expired, err := s.Expired(now); err != nil {
log.WithFields(log.Fields{"app": a.name, "now": now, "box": dest.Box(), "snapshot": s.String(), "call": "Expired", "error": err}).Errorf("") log.WithFields(log.Fields{"app": a.name, "now": now, "box": dest.Box(), "snapshot": s.String(), "call": "Expired", "error": err}).Errorf("")
return err return err
} else if expired { } else if expired {
@ -202,12 +207,33 @@ func (a *App) SanityCheck() error {
log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "path": src.Path(), "error": err}).Errorf("") log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "path": src.Path(), "error": err}).Errorf("")
return err return err
} }
for _, s := range b.zfs.filesystems[src.Path()].snapshots {
if !s.Valid() {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
}
}
} }
onlineDestinations := 0 onlineDestinations := 0
for _, dest := range a.destinations { for _, dest := range a.destinations {
if cfg.box[dest.Box()].online { b := cfg.box[dest.Box()]
if b.online {
onlineDestinations++ onlineDestinations++
for _, src := range a.sources {
dest2 := dest.Append("/" + src.Box() + "/" + src.Path())
for _, s := range b.zfs.filesystems[dest2.Path()].snapshots {
if !s.Valid() {
if err := s.Delete(); err != nil {
log.WithFields(log.Fields{"app": a.name, "box": src.Box(), "snapshot": s.String(), "call": "Delete", "error": err}).Errorf("")
return err
}
}
}
}
} }
} }
if onlineDestinations == 0 { if onlineDestinations == 0 {