From dbce986af66cf437cee869afd1966657f8eea428 Mon Sep 17 00:00:00 2001 From: Sam Chow Date: Fri, 31 Aug 2018 13:16:20 -0400 Subject: [PATCH] Setup reroutes when complete, fix gunicorn check --- config_app/config_endpoints/api/suconfig.py | 7 +------ config_app/js/setup/setup.component.js | 1 - health/services.py | 5 +++-- static/js/pages/incomplete-setup.js | 6 +++++- util/config/configutil.py | 5 +---- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/config_app/config_endpoints/api/suconfig.py b/config_app/config_endpoints/api/suconfig.py index fdf58ee3b..c9ce67c00 100644 --- a/config_app/config_endpoints/api/suconfig.py +++ b/config_app/config_endpoints/api/suconfig.py @@ -35,15 +35,11 @@ class SuperUserConfig(ApiResource): 'description': 'Updates the YAML config file', 'required': [ 'config', - 'hostname' ], 'properties': { 'config': { 'type': 'object' }, - 'hostname': { - 'type': 'string' - }, 'password': { 'type': 'string' }, @@ -66,10 +62,9 @@ class SuperUserConfig(ApiResource): # Note: This method is called to set the database configuration before super users exists, # so we also allow it to be called if there is no valid registry configuration setup. config_object = request.get_json()['config'] - hostname = request.get_json()['hostname'] # Add any enterprise defaults missing from the config. - add_enterprise_config_defaults(config_object, app.config['SECRET_KEY'], hostname) + add_enterprise_config_defaults(config_object, app.config['SECRET_KEY']) # Write the configuration changes to the config override file. config_provider.save_config(config_object) diff --git a/config_app/js/setup/setup.component.js b/config_app/js/setup/setup.component.js index e3023d273..c945b263c 100644 --- a/config_app/js/setup/setup.component.js +++ b/config_app/js/setup/setup.component.js @@ -278,7 +278,6 @@ const templateUrl = require('./setup.html'); 'config': { 'DB_URI': $scope.databaseUri }, - 'hostname': window.location.host }; if ($scope.currentState.hasDatabaseSSLCert) { diff --git a/health/services.py b/health/services.py index 1ceab38b5..4f638d1b6 100644 --- a/health/services.py +++ b/health/services.py @@ -12,8 +12,9 @@ def _check_gunicorn(endpoint): client = app.config['HTTPCLIENT'] hostname_parts = app.config['SERVER_HOSTNAME'].split(':') port = '' - if len(hostname_parts) == 2: - port = ':' + hostname_parts[1] + if hostname_parts[0] == 'localhost': + if len(hostname_parts) == 2: + port = ':' + hostname_parts[1] scheme = app.config['PREFERRED_URL_SCHEME'] if app.config.get('EXTERNAL_TLS_TERMINATION', False): diff --git a/static/js/pages/incomplete-setup.js b/static/js/pages/incomplete-setup.js index 8a376d743..b33d5f3cc 100644 --- a/static/js/pages/incomplete-setup.js +++ b/static/js/pages/incomplete-setup.js @@ -10,7 +10,11 @@ }) }]); - function IncompleteSetupCtrl($scope, $timeout, ApiService, Features, UserService, ContainerService, CoreDialog) { + function IncompleteSetupCtrl($scope, $location, $timeout, ApiService, Features, UserService, ContainerService, CoreDialog, Config) { + if (Config['SETUP_COMPLETE']) { + $location.path('/'); + return; + } if (!Features.SUPER_USERS) { return; } diff --git a/util/config/configutil.py b/util/config/configutil.py index 45c032a2c..c9c037c11 100644 --- a/util/config/configutil.py +++ b/util/config/configutil.py @@ -6,7 +6,7 @@ def generate_secret_key(): return str(cryptogen.getrandbits(256)) -def add_enterprise_config_defaults(config_obj, current_secret_key, hostname): +def add_enterprise_config_defaults(config_obj, current_secret_key): """ Adds/Sets the config defaults for enterprise registry config. """ # These have to be false. config_obj['TESTING'] = False @@ -81,9 +81,6 @@ def add_enterprise_config_defaults(config_obj, current_secret_key, hostname): config_obj['LOG_ARCHIVE_LOCATION'] = 'default' - if not 'SERVER_HOSTNAME' in config_obj: - config_obj['SERVER_HOSTNAME'] = hostname - # Misc configuration. config_obj['PREFERRED_URL_SCHEME'] = config_obj.get('PREFERRED_URL_SCHEME', 'http') config_obj['ENTERPRISE_LOGO_URL'] = config_obj.get(