Make sure the Quay Enterprise Kubernetes namespace exists

Prevents config from failing to save. Also clarifies any other errors that do occur.

Fixes #1449
This commit is contained in:
Joseph Schorr 2016-08-26 13:50:22 -04:00
parent 08e9a39099
commit 3f9c82462f

View file

@ -58,11 +58,20 @@ class KubernetesConfigProvider(FileConfigProvider):
def _assert_success(self, response):
if response.status_code != 200:
logger.error('K8s API call failed with response: %s => %s', response.status_code,
logger.error('Kubernetes API call failed with response: %s => %s', response.status_code,
response.text)
raise CannotWriteConfigException('K8s API call failed. Please report this to support')
raise CannotWriteConfigException('Kubernetes API call failed: %s' % response.text)
def _update_secret_file(self, filename, value):
# Check first that the namespace for Quay Enterprise exists. If it does not, report that
# as an error, as it seems to be a common issue.
namespace_url = 'namespaces/%s' % (QE_NAMESPACE)
response = self._execute_k8s_api('GET', namespace_url)
if response.status_code != 200:
msg = 'A Kubernetes namespace with name `%s` must be created to save config' % QE_NAMESPACE
raise CannotWriteConfigException(msg)
# Save the secret to the namespace.
secret_data = {}
secret_data[filename] = base64.b64encode(value)