-
Notifications
You must be signed in to change notification settings - Fork 63
Adds support for including custom executor jobs in /jobs #756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to update the /list
endpoint later?
scheduler/src/cook/mesos/api.clj
Outdated
@@ -2041,7 +2040,8 @@ | |||
::start-ms (parse-long-default start-ms nil) | |||
::limit (parse-int-default limit Integer/MAX_VALUE) | |||
::end-ms (parse-long-default end-ms (System/currentTimeMillis)) | |||
::name-filter-fn (name-filter-str->name-filter-fn name)}] | |||
::name-filter-fn (name-filter-str->name-filter-fn name) | |||
::include-custom-executor? (Boolean/parseBoolean include-custom-executor)}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: It's probably better to use Boolean/valueOf
here so as to avoid the implicit auto-boxing. (valueOf
returns a Boolean
object, whereas parseBoolean
returns a boolean
primitive).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
scheduler/src/cook/mesos/util.clj
Outdated
(take-while #(and (< (:e %) entid-end) | ||
(= (:a %) job-user-entid) | ||
(= (:v %) user))) | ||
(map #(:e %)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
η-reduction! (map #(:e %))
→ (map :e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
scheduler/src/cook/mesos/util.clj
Outdated
(filter #(< (.getTime (:job/submit-time %)) (.getTime end))) | ||
(filter #(= state-keyword (:job/state %))))] | ||
(cond->> jobs | ||
(not include-custom-executor?) (filter #(not (:job/custom-executor %)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was carried over from the old code, but can we change the (filter #(not (:job/custom-executor %))
to (remove :job/custom-executor)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I don't understand the question -- this PR does update the |
scheduler/src/cook/mesos/api.clj
Outdated
@@ -2015,8 +2015,7 @@ | |||
:malformed? (fn [ctx] | |||
;; since-hours-ago is included for backwards compatibility but is deprecated | |||
;; please use start-ms and end-ms instead | |||
(let [{:keys [state user since-hours-ago start-ms end-ms limit name] | |||
:as params} | |||
(let [{:keys [state user since-hours-ago start-ms end-ms limit name include-custom-executor]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: lexicographic order
I didn't see any swagger updates, so I assumed you hadn't touched the actual endpoint. I didn't realize that it doesn't have any swagger annotations (#307). 😢 I guess that's another thing to fix whenever we get around to fixing our outdated swagger docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed my pass, added some comments.
(set/difference states util/instance-states) | ||
(if (set/superset? states util/instance-states) | ||
(-> states (set/difference util/instance-states) (conj "completed")) | ||
states))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be easier to read:
(def terminal states #{"completed" "failed" "success"})
...
(if (some states terminal-states)
(-> states (set/difference terminal-states) (conj "completed"))
states)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the current (and desired) behavior:
(api/normalize-list-states #{"success" "failed" "completed"})
=> #{"completed"}
(api/normalize-list-states #{"success" "failed"})
=> #{"completed"}
(api/normalize-list-states #{"success"})
=> #{"success"}
(api/normalize-list-states #{"failed"})
=> #{"failed"}
(api/normalize-list-states #{"completed"})
=> #{"completed"}
I don't think your suggestion will have the same results when states
is #{"success"}
, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
scheduler/src/cook/mesos/api.clj
Outdated
(-> states (set/difference util/instance-states) (conj "completed")) | ||
states))) | ||
|
||
(defn parse-time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong in util
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
scheduler/src/cook/mesos/api.clj
Outdated
(or (tf/parse s) | ||
(tc/from-long (Long/parseLong s)))) | ||
|
||
(defn- parse-int-default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong in util
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
(let [pattern (name-filter-str->name-filter-pattern name)] | ||
#(re-matches pattern %)))) | ||
|
||
(defn job-list-request-malformed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are start
and end
required parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
(is (= 201 (:status response-1))) | ||
(is (= 2 (count jobs))) | ||
(is (= (:uuid response-2) (-> jobs first (get "uuid")))) | ||
(is (= (:uuid response-1) (-> jobs second (get "uuid")))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we assert on the :job/custom-executor
flags of the two jobs also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
scheduler/src/cook/mesos/util.clj
Outdated
(filter #(< (.getTime (:job/submit-time %)) (.getTime end))) | ||
(filter #(= state-keyword (:job/state %))))] | ||
(cond->> jobs | ||
(not include-custom-executor?) (remove :job/custom-executor)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If include custom-exector jobs, do you need to check the commit-latch to avoid returning uncommitted jobs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, this is done now
@shamsimam @sradack Any additional feedback on this? |
Can we merge? |
* Adds support for including custom executor jobs in /list * Fixes broken unit tests * Addresses feedback from code review * Adds support for listing jobs with /jobs * Feedback from code review * Removes uncommitted jobs from results * Fixes the filtering for non-custom-executor jobs * Marks test_kill_task_terminate_with_sigterm as xfail * Adds missing import
Changes proposed in this PR
/jobs
/jobs
will not filter out custom executor jobsWhy are we making these changes?
We want to give users and tools the option of including custom executor jobs when listing (while maintaining backwards compatibility).