 (let [kill-restart-threshold-exceeded-pod-thread-pool (Executors/newFixedThreadPool 1)]
   (defn kill-restart-threshold-exceeded-pod
     "Processes killing of a frequently restarting pod (service instance)."
-    [scheduler {:keys [k8s/pod-name k8s/restart-count service-id] :as instance}]
+    [scheduler-config {:keys [k8s/pod-name k8s/restart-count service-id] :as instance}]
     (au/execute
       (fn kill-restart-threshold-exceeded-pod-task []
         (try
           (log/info "deleting frequently restarting pod"
                     {:pod-name pod-name :restart-count restart-count :service-id service-id})
-          (hard-delete-service-instance scheduler instance)
+          (hard-delete-service-instance scheduler-config instance)
           (catch Exception ex
             (log/error ex "error in deleting frequently restarting pod" pod-name))))
       kill-restart-threshold-exceeded-pod-thread-pool)))
 
 (defn pod->ServiceInstance
   "Convert a Kubernetes Pod JSON response into a Waiter Service Instance record."
-  [{:keys [api-server-url leader?-fn restart-kill-threshold] :as scheduler} pod]
+  [{:keys [api-server-url leader?-fn restart-kill-threshold] :as scheduler-config} pod]
   (try
     (let [;; waiter-app is the first container we register
           primary-container-restart-count (or (get-in pod [:status :containerStatuses 0 :restartCount]) 0)

(defn instances-breakdown!
  "Get all Waiter Service Instances associated with the given Waiter Service.
   Grouped by liveness status, i.e.: {:active-instances [...] :failed-instances [...] :killed-instances [...]}"
  [{:keys [service-id->failed-instances-transient-store] :as scheduler} {service-id :id :as basic-service-info}]
  {:active-instances (get-service-instances! scheduler basic-service-info)
   :failed-instances (-> @service-id->failed-instances-transient-store (get service-id) vec)})

(defn- patch-object-json

  "Force kill the Kubernetes pod corresponding to the given Waiter Service Instance.
   Does not adjust ReplicaSet replica count; preventing scheduling of a replacement pod must be ensured by the callee.
   Returns nil on success, but throws on failure."
  [{:keys [api-server-url] :as scheduler-config} {:keys [service-id] :as instance}]
  (let [pod-url (instance->pod-url api-server-url instance)]
    (try
      (api-request pod-url scheduler-config :request-method :delete)
      (catch Throwable t
        (log/error t "Error force-killing pod")))))

