code: def test_agent_restart_cmd_container_failure(
      restartable_managed_cluster: ManagedCluster, command_duration: int
  ) -> None:
      # Launch a cmd, kill agent, wait for reconnect timeout, check it's not marked as success.
      # Reconnect timeout is ~25 seconds. We'd like to both test tasks that take
      # longer (60 seconds) and shorter (10 seconds) than that.
      restartable_managed_cluster.ensure_agent_ok()
      try:
          command_id = run_command(command_duration)
          wait_for_command_state(command_id, "RUNNING", 10)
  
          for _i in range(10):
              if (
                  len(
                      list(_local_container_ids_for_command(command_id))
                  )
                  > 0
              ):
                  break
              time.sleep(1)
          else:
              pytest.fail(
                  f"Failed to find the command container id after {_i} ticks"
              )
  
          restartable_managed_cluster.kill_agent()
  
          # Container should still be alive.
          assert list(_local_container_ids_for_command(command_id))
          for _i in range(command_duration + 10):
              if (
                  len(
                      list(_local_container_ids_for_command(command_id))
                  )
                  == 0
              ):
                  break
              time.sleep(1)
          else:
              pytest.fail(
                  f"command container didn't terminate after {_i} ticks"
              )
          wait_for_command_state(command_id, "TERMINATED", 30)
          assert (
              "success"
              not in get_command_info(command_id)["exitStatus"]
          )
      except Exception:
          restartable_managed_cluster.restart_agent()
          raise
      else:
          restartable_managed_cluster.restart_agent()
  
imports: import json
  import subprocess
  import time
  import uuid
  from pathlib import Path
  from typing import Any, Dict, Iterator, Tuple
  import pytest
  from determined.common.api.bindings import experimentv1State
  from tests import config
  from tests import experiment
  from .managed_cluster import ManagedCluster
  from .utils import assert_command_succeeded, get_command_info, run_command, wait_for_command_state
label_desc: Use image node_id 7 for calling a global function with example usage: test_agent_restart_cmd_container_failure(restartable_managed_cluster, command_duration) without return types