def run_command()

in functions/source/KubeManifest/lambda_function.py [0:0]


def run_command(command):
    retries = 0
    while True:
        try:
            try:
                logger.debug("executing command: %s" % command)
                output = subprocess.check_output(shlex.split(command), stderr=subprocess.STDOUT).decode("utf-8")
                logger.debug(output)
            except subprocess.CalledProcessError as exc:
                logger.error("Command failed with exit code %s, stderr: %s" % (exc.returncode,
                                                                               exc.output.decode("utf-8")))
                raise Exception(exc.output.decode("utf-8"))
            return output
        except Exception as e:
            if 'Unable to connect to the server' not in str(e) or retries >= 5:
                raise
            logger.debug("{}, retrying in 5 seconds".format(e))
            sleep(5)
            retries += 1