                         watch-socket-timeout-ms (assoc :socket-timeout-ms watch-socket-timeout-ms))
         watch-state (atom nil)
         scheduler-config {:api-server-url url
-                          :http-client http-client
                           :cluster-name cluster-name
                           :container-running-grace-secs container-running-grace-secs
+                          :http-client http-client
+                          :leader?-fn leader?-fn
                           :replicaset-api-version replicaset-api-version
                           :restart-expiry-threshold restart-expiry-threshold
                           :restart-kill-threshold restart-kill-threshold

  "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} {:keys [service-id] :as instance}]
  (let [pod-url (instance->pod-url api-server-url instance)]
    (try
      (api-request pod-url scheduler :request-method :delete)
      (catch Throwable t
        (log/error t "Error force-killing pod")))))


                                                                  (some? state) (assoc :state state))))
                                                            container-statuses))))]
      (when exceeded-restart-kill-threshold?
        (try
          (if (leader?-fn)
            (kill-restart-threshold-exceeded-pod scheduler-config instance)
            (log/info "skipping deleting frequently restarting pod on non-leader"
                      {:pod-name pod-name :restart-count primary-container-restart-count :service-id service-id}))
          (catch Throwable e
            (log/error e "error killing frequently restarting pod" pod-name))))
      instance)
    (catch Throwable e
      (log/error e "error converting pod to waiter service instance" pod)
