From 6aac597d9fb7c14cbaa8644b3bb5b9f856fedb03 Mon Sep 17 00:00:00 2001 From: Sannie Kwakman Date: Mon, 29 Feb 2016 10:26:31 +0100 Subject: [PATCH 1/3] errors during schedule no longer fail silently. Additionally, added logging for mentioning cleanup has performed. This eases validation of schedule configuration. --- .../com/xebia/visualreview/schedule.clj | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/clojure/com/xebia/visualreview/schedule.clj b/src/main/clojure/com/xebia/visualreview/schedule.clj index 88afbd1..0e8b880 100644 --- a/src/main/clojure/com/xebia/visualreview/schedule.clj +++ b/src/main/clojure/com/xebia/visualreview/schedule.clj @@ -3,23 +3,32 @@ [slingshot.slingshot :as ex] [clojure.tools.logging :as log] [com.xebia.visualreview.service.cleanup :as cleanup] - [com.xebia.visualreview.service.persistence.database :as db])) + [com.xebia.visualreview.service.persistence.database :as db] + [com.xebia.visualreview.service.service-util :as sutil])) (defn- try-catch-all [form] (ex/try+ ~form (catch Object o# - (log/debug "Caught exception while running task")))) + (log/warn "Caught exception while running task" ~o#)) + (catch Exception e + (log/warn "Caught exception while running task" e)))) (defn generate-cleanup-task [] {:id :cleanup-orphans-task :handler (fn [t opts] - (do - (log/debug "Running cleanup task..") - (try-catch-all (cleanup/cleanup-old-runs! db/conn)) - (try-catch-all (cleanup/cleanup-orphans! db/conn)) - (log/debug "..cleanup task ended"))) + (ex/try+ + (sutil/attempt + (do + (log/info "Running cleanup task..") + (cleanup/cleanup-old-runs! db/conn) + (cleanup/cleanup-orphans! db/conn) + (log/info "..cleanup task ended")) + "Something went wrong during scheduled cleanup: %s" + :cleanup-error) + (catch Object o + (log/error (:message o))))) :schedule (:cleanup-schedule com.xebia.visualreview.config/env) :opts {}}) From 495edabb863c4a628bbc1a4b1bda531996357fc9 Mon Sep 17 00:00:00 2001 From: Sannie Kwakman Date: Mon, 29 Feb 2016 10:27:03 +0100 Subject: [PATCH 2/3] fixed issue where cleanup fails in a multi-project environment --- src/main/clojure/com/xebia/visualreview/service/suite.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clojure/com/xebia/visualreview/service/suite.clj b/src/main/clojure/com/xebia/visualreview/service/suite.clj index a4f7f67..2d8b088 100644 --- a/src/main/clojure/com/xebia/visualreview/service/suite.clj +++ b/src/main/clojure/com/xebia/visualreview/service/suite.clj @@ -82,7 +82,7 @@ ::delete-by-id-failed)) (def ^:private get-run-ids-per-suite-sql - "SELECT run.suite_id, GROUP_CONCAT(id ORDER BY START_TIME DESC SEPARATOR ',') as runids from RUN") + "SELECT run.suite_id, GROUP_CONCAT(id ORDER BY START_TIME DESC SEPARATOR ',') as runids from RUN GROUP BY SUITE_ID") (defn get-run-ids-per-suite "Returns {:suite-id :run-ids (lazy seq of run ids ordered by start-date desc)}" [conn] From 0ac303366b5d551717bfb48dc9f52b61879223b5 Mon Sep 17 00:00:00 2001 From: Sannie Kwakman Date: Mon, 29 Feb 2016 10:31:14 +0100 Subject: [PATCH 3/3] added fixed issues to changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10ec6e9..3a545fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.1.3 + +### Features and improvements +* Scheduled cleanup now logs a message at start and finish. This enables users to validate their schedule configuration. + +### Bugfixes +* Errors during cleanup schedule no longer fail without logging an error. +* Fixes bug where runs are no longer cleaned up when there are multiple projects defined in VisualReview + ## 0.1.2 ### Features and improvements