-- | Kill a job. Fails if job is already terminated.
killJob :: (TS m, MonadError JobError m) => Job.Name -> m ()
killJob name = existing _AJob name >>= \js -> case js ^. Job.stage of
    Killing                  -> pure ()
    s | isTerminationStage s -> pure ()
      | otherwise            -> do
            ES.setJobStage name Killing
            ES.schedule $ KillJob (js ^. Job.spec) (js ^. Job.uuid)
killJob :: (TS m, MonadError JobError m) => Job.Name -> m ()
killJob name = existing _AJob name >>= \js -> case js ^. Job.stage of
    Killing                  -> pure ()
    s | isTerminationStage s -> pure ()
      | otherwise            -> do
            ES.setJobStage name Killing
            ES.schedule $ KillJob (js ^. Job.spec) (js ^. Job.uuid)
killJob name = existing _AJob name >>= \js -> case js ^. Job.stage of
    Killing                  -> pure ()
    s | isTerminationStage s -> pure ()
      | otherwise            -> do
            ES.setJobStage name Killing
            ES.schedule $ KillJob (js ^. Job.spec) (js ^. Job.uuid)