From 536c02dc55f8259c9aecbbc85473c7246d5d954e Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Tue, 25 May 2021 15:13:56 -0400 Subject: [PATCH] Simplify hostname parsing --- awx/main/scheduler/kubernetes.py | 8 ++------ awx/main/utils/external_logging.py | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/awx/main/scheduler/kubernetes.py b/awx/main/scheduler/kubernetes.py index dd27402b00..514f9e4624 100644 --- a/awx/main/scheduler/kubernetes.py +++ b/awx/main/scheduler/kubernetes.py @@ -7,6 +7,7 @@ from urllib import parse as urlparse from django.conf import settings from kubernetes import client, config from django.utils.functional import cached_property +from django.utils.translation import ugettext_lazy as _ from awx.main.utils.common import parse_yaml_or_json from awx.main.utils.execution_environments import get_default_pod_spec @@ -56,11 +57,10 @@ class PodManager(object): def create_secret(self, job): registry_cred = job.execution_environment.credential host = registry_cred.get_input('host') - scheme = 'https' # urlparse requires '//' to be provided if scheme is not specified original_parsed = urlparse.urlsplit(host) if (not original_parsed.scheme and not host.startswith('//')) or original_parsed.hostname is None: - host = '%s://%s' % (scheme, host) + host = 'https://%s' % (host) parsed = urlparse.urlsplit(host) host = parsed.hostname if parsed.port: @@ -102,8 +102,6 @@ class PodManager(object): ) full_error_msg = '{0}: {1}'.format(error_msg, str(e)) logger.exception(full_error_msg) - job.job_explanation = error_msg - job.save() raise PermissionError(full_error_msg) if replace_secret: @@ -121,8 +119,6 @@ class PodManager(object): ) full_error_msg = '{0}: {1}'.format(error_msg, str(e)) logger.exception(full_error_msg) - job.job_explanation = error_msg - job.save() # let job continue for the case where secret was created manually and cluster cred doesn't have permission to create a secret except Exception as e: error_msg = 'Failed to create imagePullSecret for container group {}'.format(job.instance_group.name) diff --git a/awx/main/utils/external_logging.py b/awx/main/utils/external_logging.py index 3a86d24df7..26f434a4e4 100644 --- a/awx/main/utils/external_logging.py +++ b/awx/main/utils/external_logging.py @@ -47,11 +47,10 @@ def construct_rsyslog_conf_template(settings=settings): return tmpl if protocol.startswith('http'): - scheme = 'https' # urlparse requires '//' to be provided if scheme is not specified original_parsed = urlparse.urlsplit(host) if (not original_parsed.scheme and not host.startswith('//')) or original_parsed.hostname is None: - host = '%s://%s' % (scheme, host) + host = 'https://%s' % (host) parsed = urlparse.urlsplit(host) host = escape_quotes(parsed.hostname)