parameters: (pod_name, exec_command, timeout=60)
docstring: work as the command (with timeout): kubectl exec 'pod_name' 'exec_command
docstring_summary: work as the command (with timeout): kubectl exec 'pod_name' 'exec_command
docstring_tokens: work as the command ( with timeout ) : kubectl exec pod_name exec_command
function: def pod_exec(pod_name, exec_command, timeout=60):
      """work as the command (with timeout): kubectl exec 'pod_name' 'exec_command'"""
      try:
          logger.debug("Exec on pod %s: %s", pod_name, exec_command)
          client = stream(
              k8s_core_api.connect_get_namespaced_pod_exec,
              name=pod_name,
              namespace="default",
              command=exec_command,
              stderr=True,
              stdin=False,
              stdout=True,
              tty=False,
              _preload_content=False,
          )
          client.run_forever(timeout=timeout)
  
          err = yaml.full_load(client.read_channel(ERROR_CHANNEL))
          if err is None:
              return [-1, "Timeout"]
  
          if err["status"] == "Success":
              status_code = 0
          else:
              logger.debug("Exec on pod %s failed. cmd: %s, err: %s.", pod_name,
                           exec_command, err)
              status_code = int(err["details"]["causes"][0]["message"])
          output = client.read_all()
          logger.info("Exec on pod %s, status: %s, cmd: %s, output: %s", pod_name,
                      status_code, exec_command, output)
          return [status_code, output]
      except ApiException as err:
          logger.exception("Exec on pod %s error. cmd: %s, err: %s.", pod_name,
                           exec_command, err)
          return [-1, err.message]
function_tokens: def pod_exec ( pod_name , exec_command , timeout = 60 ) : try : logger . debug ( "Exec on pod %s: %s" , pod_name , exec_command ) client = stream ( k8s_core_api . connect_get_namespaced_pod_exec , name = pod_name , namespace = "default" , command = exec_command , stderr = True , stdin = False , stdout = True , tty = False , _preload_content = False , ) client . run_forever ( timeout = timeout ) err = yaml . full_load ( client . read_channel ( ERROR_CHANNEL ) ) if err is None : return [ - 1 , "Timeout" ] if err [ "status" ] == "Success" : status_code = 0 else : logger . debug ( "Exec on pod %s failed. cmd: %s, err: %s." , pod_name , exec_command , err ) status_code = int ( err [ "details" ] [ "causes" ] [ 0 ] [ "message" ] ) output = client . read_all ( ) logger . info ( "Exec on pod %s, status: %s, cmd: %s, output: %s" , pod_name , status_code , exec_command , output ) return [ status_code , output ] except ApiException as err : logger . exception ( "Exec on pod %s error. cmd: %s, err: %s." , pod_name , exec_command , err ) return [ - 1 , err . message ]