Skip to content
Browse files

Adds pool name to several log messages (#1217)

* Adds pool name to several log messages

* Fixes broken unit tests
  • Loading branch information...
dposada authored and nsinkov committed Sep 24, 2019
1 parent 73af1eb commit 5c2b367aefb8e72cc1bef997a2520b3dc4d88936
Showing with 14 additions and 11 deletions.
  1. +1 −0 .gitignore
  2. +7 −7 scheduler/src/cook/scheduler/scheduler.clj
  3. +6 −4 scheduler/test/cook/test/scheduler/scheduler.clj
@@ -33,3 +33,4 @@ src/cfg/current.clj
@@ -486,12 +486,11 @@
Returns {:matches (list of tasks that got matched to the offer)
:failures (list of unmatched tasks, and why they weren't matched)}"
[db ^TaskScheduler fenzo considerable offers rebalancer-reservation-atom]
(log/info "Matching" (count offers) "offers to" (count considerable) "jobs with fenzo")
(log/debug "tasks to scheduleOnce" considerable)
[db ^TaskScheduler fenzo considerable offers rebalancer-reservation-atom pool-name]
(log/info "In" pool-name "pool, matching" (count offers) "offers to" (count considerable) "jobs with fenzo")
(log/debug "In" pool-name "pool, tasks to scheduleOnce" considerable)
(dl/update-cost-staleness-metric considerable)
(let [t (System/currentTimeMillis)
_ (log/debug "tasks to scheduleOnce" considerable)
leases (mapv #(->VirtualMachineLeaseAdapter % t) offers)
considerable->task-id (plumbing.core/map-from-keys (fn [_] (str (d/squuid))) considerable)
guuid->considerable-cotask-ids (util/make-guuid->considerable-cotask-ids considerable->task-id)
@@ -515,12 +514,12 @@
assignments (.. result getResultMap values)]
(doall (map (fn [^VirtualMachineLease lease]
(when (-> lease :offer :reject-after-match-attempt)
(log/info "Retracting lease" (-> lease :offer :id))
(log/info "In" pool-name "pool, retracting lease" (-> lease :offer :id))
(locking fenzo
(.expireLease fenzo (.getId lease)))))

(log/debug "Found this assignment:" result)
(log/debug "In" pool-name "pool, found this assignment:" result)

{:matches (mapv (fn [assignment]
{:leases (.getLeasesUsed assignment)
@@ -745,7 +744,8 @@
; matches is a vector of maps of {:hostname .. :leases .. :tasks}
{:keys [matches failures]} (timers/time!
(timers/timer (metric-title "handle-resource-offer!-match-duration" pool-name))
(match-offer-to-schedule db fenzo considerable-jobs offers rebalancer-reservation-atom))
(match-offer-to-schedule db fenzo considerable-jobs offers
rebalancer-reservation-atom pool-name))
_ (log/debug "In" pool-name "pool, got matches:" matches)
offers-scheduled (for [{:keys [leases]} matches
lease leases]
@@ -377,7 +377,8 @@
framework-id (str "framework-id-" (UUID/randomUUID))
fenzo-maker #(sched/make-fenzo-scheduler nil 100000 nil 1)] ; The params are for offer declining, which should never happen
(testing "Consume no schedule cases"
(are [schedule offers] (= [] (:matches (sched/match-offer-to-schedule (db c) (fenzo-maker) schedule offers (atom {}))))
(are [schedule offers] (= [] (:matches (sched/match-offer-to-schedule (db c) (fenzo-maker) schedule
offers (atom {}) nil)))
[] (offer-maker 0 0)
[] (offer-maker 2 2000)
schedule (offer-maker 0 0)
@@ -388,15 +389,15 @@
;; We're looking for one task to get assigned
(are [offers] (= 1 (count (mapcat :tasks
(:matches (sched/match-offer-to-schedule
(db c) (fenzo-maker) schedule offers (atom {}))))))
(db c) (fenzo-maker) schedule offers (atom {}) nil)))))
(offer-maker 1 1000)
(offer-maker 1.5 1500)))
(testing "Consume full schedule cases"
;; We're looking for the entire schedule to get assigned
(are [offers] (= (count schedule)
(count (mapcat :tasks
(:matches (sched/match-offer-to-schedule
(db c) (fenzo-maker) schedule offers (atom {}))))))
(db c) (fenzo-maker) schedule offers (atom {}) nil)))))
(offer-maker 4 4000)
(offer-maker 5 5000)))))

@@ -435,7 +436,8 @@
high-priority (map #(d/entity (d/db conn) %) high-priority-ids)
considerable (concat high-priority low-priority)]
(testing "Scheduling order respected?"
(let [schedule (sched/match-offer-to-schedule (d/db conn) fenzo considerable [(offer-maker 1.0 "empty_host")] (atom {}))]
(let [schedule (sched/match-offer-to-schedule (d/db conn) fenzo considerable
[(offer-maker 1.0 "empty_host")] (atom {}) nil)]
(is (= {"empty_host" ["high-priority"]}
(->> schedule

0 comments on commit 5c2b367

Please sign in to comment.
You can’t perform that action at this time.