          (get-in [:state :terminated])
          (nil?))))
 
+(defn- drop-managed-fields
+  "Removes the :metadata :managedFields entry from a k8s object."
+  [k8s-obj]
+  (utils/dissoc-in k8s-obj [:metadata :managedFields]))
+
 (defn streaming-api-request
   "Make a long-lived HTTP request to the Kubernetes API server using the configured authentication.
    If data is provided via :body, the application/json content type is added automatically.

                      {:watch-resource resource-name
                       :watch-response update-json}))
      ;; Drop managedFields from response objects when present (much too verbose!)
      ;; https://github.com/kubernetes/kubernetes/issues/90066#issuecomment-626828512
      (utils/dissoc-in update-json [:object :metadata :managedFields]))))

(defn api-request
  "Make an HTTP request to the Kubernetes API server using the configured authentication.

                              :accept "application/json"
                              (cond-> options
                                auth-str (assoc-in [:headers "Authorization"] auth-str)
                                (and (not content-type) body) (assoc :content-type "application/json"))))
          result-type (:kind result)
          ;; Drop managedFields from response objects when present (much too verbose!)
          ;; https://github.com/kubernetes/kubernetes/issues/90066
          result (cond
                   (or (= "Pod" result-type)
                       (= "ReplicaSet" result-type))
                   (drop-managed-fields result)
                   (or (= "PodList" result-type)
                       (= "ReplicaSetList" result-type))
                   (update result :items #(mapv drop-managed-fields %))
                   :else result)]
      (scheduler/log "response from K8s API server:" result)
      result)
    (catch [:status http-400-bad-request] response
