in apply/src/awsqs_kubernetes_resource/utils.py [0:0]
def run_command(command, cluster_name, session):
if cluster_name and session:
if proxy_needed(cluster_name, session):
put_function(session, cluster_name)
manifest = None
if Path("/tmp/manifest.yaml").is_file():
with open("/tmp/manifest.yaml", "r") as fh:
manifest = fh.read()
resp = proxy_call(cluster_name, manifest, command, session)
log_output(resp)
return resp
retries = 0
while True:
try:
try:
LOG.debug("executing command: %s" % command)
output = subprocess.check_output(
shlex.split(command), stderr=subprocess.STDOUT
).decode("utf-8")
log_output(output)
except subprocess.CalledProcessError as exc:
LOG.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
LOG.debug("{}, retrying in 5 seconds".format(e))
sleep(5)
retries += 1