def job_succeeded(tfjob):
  """Returns true if the TFJob succeeded; false otherwise.

  Args:
    tfjob: The TFJob custom resource returned from K8s.
  """
  last_condition = tfjob.get("status", {}).get("conditions", [{}])[-1]
  return last_condition.get("type", "").lower() == "succeeded"