1
0
Fork 0

Count Snapshot upgrades

master
Philip O'Toole 10 months ago
parent 0b233acc9f
commit f15f2b95b3

@ -21,6 +21,8 @@ import (
const (
persistSize = "latest_persist_size"
persistDuration = "latest_persist_duration"
upgradeOk = "upgrade_ok"
upgradeFail = "upgrade_fail"
)
const (
@ -41,6 +43,8 @@ func ResetStats() {
stats.Init()
stats.Add(persistSize, 0)
stats.Add(persistDuration, 0)
stats.Add(upgradeOk, 0)
stats.Add(upgradeFail, 0)
}
// LockingSink is a wrapper around a SnapshotSink that ensures that the

@ -21,7 +21,12 @@ const (
// Upgrade writes a copy of the 7.x-format Snapshot dircectory at 'old' to a
// new Snapshot directory at 'new'. If the upgrade is successful, the
// 'old' directory is removed before the function returns.
func Upgrade(old, new string, logger *log.Logger) error {
func Upgrade(old, new string, logger *log.Logger) (retErr error) {
defer func() {
if retErr != nil {
stats.Add(upgradeFail, 1)
}
}()
newTmpDir := tmpName(new)
// If a temporary version of the new snapshot exists, remove it. This implies a
@ -138,6 +143,7 @@ func Upgrade(old, new string, logger *log.Logger) error {
return fmt.Errorf("failed to remove old snapshot directory %s: %s", old, err)
}
logger.Printf("upgraded snapshot directory %s to %s", old, new)
stats.Add(upgradeOk, 1)
return nil
}

Loading…
Cancel
Save