From bf7e1a52f270e47b4c9a14d26e0292f4be0f4373 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Fri, 20 Nov 2015 15:02:47 -0500 Subject: [PATCH] stop reporting failures as successful updates Fixes #20. --- updater/updater.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/updater/updater.go b/updater/updater.go index 8c2fe245..1ad71b0d 100644 --- a/updater/updater.go +++ b/updater/updater.go @@ -21,10 +21,10 @@ import ( "strconv" "time" - "github.com/coreos/pkg/capnslog" "github.com/coreos/clair/database" "github.com/coreos/clair/health" "github.com/coreos/clair/utils" + "github.com/coreos/pkg/capnslog" "github.com/pborman/uuid" ) @@ -93,23 +93,16 @@ func Run(interval time.Duration, st *utils.Stopper) { doneC <- true }() - // Refresh the lock until the update is done. for done := false; !done; { select { case <-doneC: done = true case <-time.After(refreshLockDuration): + // Refresh the lock until the update is done. database.Lock(flagName, lockDuration, whoAmI) } } - // Write the last update time to the database and set the next update - // time. - now := time.Now().UTC() - database.UpdateFlag(flagName, strconv.FormatInt(now.Unix(), 10)) - healthLatestSuccessfulUpdate = now - nextUpdate = now.Add(interval) - // Unlock the update. database.Unlock(flagName, whoAmI) } else { @@ -252,7 +245,11 @@ func Update() { // Update health depending on the status of the fetchers. updateHealth(status) - + if status { + now := time.Now().UTC() + database.UpdateFlag(flagName, strconv.FormatInt(now.Unix(), 10)) + healthLatestSuccessfulUpdate = now + } log.Info("update finished") }