 ; This pod annotation signals to the cluster autoscaler that
 ; it's safe to remove the node on which the pod is running
 (def k8s-safe-to-evict-annotation "cluster-autoscaler.kubernetes.io/safe-to-evict")
+; We want nodes older than 5 minutes to get this taint. A separate process taints those old nodes
+; with this taint. Cook ignores it for scheduling purposes, but synthetic pods are configured so they
+; don't ignore it. Cook creates synthetic pods as a scaling signal. When they run on existing nodes,
+; the signal we intend to send to the autoscaler is attenuated and we autoscale much less than intended.
+;
+; We prefix the taint with the ignore-taint string so that the autoscaler won't use this when constructing exemplar new nodes.
+(def tenured-node-taint "ignore-taint.cluster-autoscaler.kubernetes.io/cook-node-tenured")
 
 (def default-shell
   "Default shell command used by our k8s scheduler to wrap and launch a job command

      ; (https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
      ; from happening. We want this pod to preempt lower priority pods
      ; (e.g. synthetic pods).
      (add-node-selector pod-spec k8s-hostname-label hostname)
      (when (seq pod-hostnames-to-avoid)
        ; Use node "anti"-affinity to disallow scheduling on nodes with particular labels
        ; (https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#node-affinity)

    (.setOperator toleration "Equal")
    (.setEffect toleration "NoSchedule")
    toleration))

(def toleration-tenured-node
  (doto (V1Toleration.)
    (.setKey tenured-node-taint)
    (.setOperator "Exists")
    (.setEffect "NoSchedule")))

(def toleration-for-deletion-candidate-of-autoscaler
  (doto (V1Toleration.)
