From a4de476a8585112c13e9de13c49b510fdcd1b222 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 14 Jan 2015 23:39:58 -0500 Subject: [PATCH 1/5] Have the health check also ping the registry endpoint to make sure it is functional. --- endpoints/index.py | 5 +++++ endpoints/web.py | 12 +++++++++++- health/healthcheck.py | 14 ++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/endpoints/index.py b/endpoints/index.py index 00221b8cc..de45f2fde 100644 --- a/endpoints/index.py +++ b/endpoints/index.py @@ -380,6 +380,11 @@ def get_search(): resp.mimetype = 'application/json' return resp +# Note: This is *not* part of the Docker index spec. This is here for our own health check, +# since we have nginx handle the _ping below. +@index.route('/_internal_ping') +def internal_ping(): + return make_response('true', 200) @index.route('/_ping') @index.route('/_ping') diff --git a/endpoints/web.py b/endpoints/web.py index 519fc5c5e..c1ce6abbc 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -156,11 +156,21 @@ def v1(): @web.route('/health', methods=['GET']) @no_cache def health(): + client = app.config['HTTPCLIENT'] + db_healthy = model.check_health() buildlogs_healthy = build_logs.check_health() + hostname_parts = app.config['SERVER_HOSTNAME'].split(':') + port = '' + if len(hostname_parts) == 2: + port = ':' + hostname_parts[1] + + registry_url = '%s://localhost%s/v1/_internal_ping' % (app.config['PREFERRED_URL_SCHEME'], port) + registry_healthy = client.get(registry_url, verify=False).status_code == 200 + check = HealthCheck.get_check(app.config['HEALTH_CHECKER'][0], app.config['HEALTH_CHECKER'][1]) - (data, is_healthy) = check.conduct_healthcheck(db_healthy, buildlogs_healthy) + (data, is_healthy) = check.conduct_healthcheck(db_healthy, buildlogs_healthy, registry_healthy) response = jsonify(dict(data=data, is_healthy=is_healthy)) response.status_code = 200 if is_healthy else 503 diff --git a/health/healthcheck.py b/health/healthcheck.py index dc0ae7e6f..f5204dff7 100644 --- a/health/healthcheck.py +++ b/health/healthcheck.py @@ -7,7 +7,7 @@ class HealthCheck(object): def __init__(self): pass - def conduct_healthcheck(self, db_healthy, buildlogs_healthy): + def conduct_healthcheck(self, db_healthy, buildlogs_healthy, registry_healthy): """ Conducts any custom healthcheck work, returning a dict representing the HealthCheck output and a boolean indicating whether the instance is healthy. @@ -31,10 +31,11 @@ class LocalHealthCheck(HealthCheck): def check_name(cls): return 'LocalHealthCheck' - def conduct_healthcheck(self, db_healthy, buildlogs_healthy): + def conduct_healthcheck(self, db_healthy, buildlogs_healthy, registry_healthy): data = { 'db_healthy': db_healthy, - 'buildlogs_healthy': buildlogs_healthy + 'buildlogs_healthy': buildlogs_healthy, + 'registry_healthy': registry_healthy } return (data, db_healthy and buildlogs_healthy) @@ -49,10 +50,11 @@ class ProductionHealthCheck(HealthCheck): def check_name(cls): return 'ProductionHealthCheck' - def conduct_healthcheck(self, db_healthy, buildlogs_healthy): + def conduct_healthcheck(self, db_healthy, buildlogs_healthy, registry_healthy): data = { 'db_healthy': db_healthy, - 'buildlogs_healthy': buildlogs_healthy + 'buildlogs_healthy': buildlogs_healthy, + 'registry_healthy': registry_healthy } # Only report unhealthy if the machine cannot connect to the DB. Redis isn't required for @@ -81,4 +83,4 @@ class ProductionHealthCheck(HealthCheck): # requests once RDS comes back up. return (data, not is_rds_working) - return (data, db_healthy) + return (data, db_healthy and registry_healthy) From 93708d0131fb1ac467a571b132a4b5c7e9128d96 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 14 Jan 2015 23:41:30 -0500 Subject: [PATCH 2/5] Add the registry value to the other returned health value --- health/healthcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/health/healthcheck.py b/health/healthcheck.py index f5204dff7..cc76c76c7 100644 --- a/health/healthcheck.py +++ b/health/healthcheck.py @@ -81,6 +81,6 @@ class ProductionHealthCheck(HealthCheck): # If RDS is down, then we still report the machine as healthy, so that it can handle # requests once RDS comes back up. - return (data, not is_rds_working) + return (data, not is_rds_working and registry_healthy) return (data, db_healthy and registry_healthy) From 2bae008bb178011c2507d112fa9ea798660e7f2f Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 16 Jan 2015 13:22:54 -0500 Subject: [PATCH 3/5] Add a timeout to the health check on the registry workers --- endpoints/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endpoints/web.py b/endpoints/web.py index c1ce6abbc..fb08ea60e 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -167,7 +167,7 @@ def health(): port = ':' + hostname_parts[1] registry_url = '%s://localhost%s/v1/_internal_ping' % (app.config['PREFERRED_URL_SCHEME'], port) - registry_healthy = client.get(registry_url, verify=False).status_code == 200 + registry_healthy = client.get(registry_url, verify=False, timeout=2).status_code == 200 check = HealthCheck.get_check(app.config['HEALTH_CHECKER'][0], app.config['HEALTH_CHECKER'][1]) (data, is_healthy) = check.conduct_healthcheck(db_healthy, buildlogs_healthy, registry_healthy) From 473a141835d7f249c8bb8230530a1cd6b3caafaf Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 16 Jan 2015 17:01:14 -0500 Subject: [PATCH 4/5] Allow for building of Dockerfiles with pull robots --- static/css/quay.css | 10 ++--- .../directives/dockerfile-build-dialog.html | 2 +- static/directives/dockerfile-build-form.html | 37 +++++++++++++++++-- static/js/app.js | 23 +++++++++--- static/partials/new-repo.html | 4 +- 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/static/css/quay.css b/static/css/quay.css index 82c1e91e8..0f7a8be9c 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -1096,12 +1096,6 @@ i.toggle-icon:hover { border: 1px dashed #ccc; } -.new-repo .initialize-repo .init-description { - color: #444; - font-size: 12px; - text-align: center; -} - .new-repo .initialize-repo .file-drop { margin: 10px; } @@ -4915,3 +4909,7 @@ i.slack-icon { #gen-token input[type="checkbox"] { margin-right: 10px; } + +.dockerfile-build-form table td { + vertical-align: top; +} diff --git a/static/directives/dockerfile-build-dialog.html b/static/directives/dockerfile-build-dialog.html index 4848b341c..5ba1f475f 100644 --- a/static/directives/dockerfile-build-dialog.html +++ b/static/directives/dockerfile-build-dialog.html @@ -15,7 +15,7 @@
+ is-ready="hasDockerfile" uploading="uploading" building="building">
-
- Upload a Dockerfile or an archive (.zip or .tar.gz) containing a Dockerfile in the root directory -
- + + + + + + + + +
Dockerfile or Archive (.tar.gz or .zip): +
Base Image Pull Credentials: + +
+ + +
+ + +
+ +
+
diff --git a/static/js/app.js b/static/js/app.js index 69f135538..b41e80b10 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -4354,6 +4354,8 @@ quayApp.directive('entitySearch', function () { if (classes.length > 1) { classes[classes.length - 1] = 'or ' + classes[classes.length - 1]; + } else if (classes.length == 0) { + return '
No matching entities found
'; } var class_string = ''; @@ -4439,7 +4441,6 @@ quayApp.directive('entitySearch', function () { $scope.$watch('namespace', function(namespace) { if (!namespace) { return; } - $scope.isAdmin = UserService.isNamespaceAdmin(namespace); $scope.isOrganization = !!UserService.getOrganization(namespace); }); @@ -6229,7 +6230,7 @@ quayApp.directive('dockerfileBuildForm', function () { scope: { 'repository': '=repository', 'startNow': '=startNow', - 'hasDockerfile': '=hasDockerfile', + 'isReady': '=isReady', 'uploadFailed': '&uploadFailed', 'uploadStarted': '&uploadStarted', 'buildStarted': '&buildStarted', @@ -6240,6 +6241,8 @@ quayApp.directive('dockerfileBuildForm', function () { }, controller: function($scope, $element, ApiService) { $scope.internal = {'hasDockerfile': false}; + $scope.pull_entity = null; + $scope.is_public = true; var handleBuildFailed = function(message) { message = message || 'Dockerfile build failed to start'; @@ -6313,8 +6316,12 @@ quayApp.directive('dockerfileBuildForm', function () { 'file_id': fileId }; + if (!$scope.is_public && $scope.pull_entity) { + data['pull_robot'] = $scope.pull_entity['name']; + } + var params = { - 'repository': repo.namespace + '/' + repo.name + 'repository': repo.namespace + '/' + repo.name, }; ApiService.requestRepoBuild(data, params).then(function(resp) { @@ -6392,9 +6399,13 @@ quayApp.directive('dockerfileBuildForm', function () { }); }; - $scope.$watch('internal.hasDockerfile', function(d) { - $scope.hasDockerfile = d; - }); + var checkIsReady = function() { + $scope.isReady = $scope.internal.hasDockerfile && ($scope.is_public || $scope.pull_entity); + }; + + $scope.$watch('pull_entity', checkIsReady); + $scope.$watch('is_public', checkIsReady); + $scope.$watch('internal.hasDockerfile', checkIsReady); $scope.$watch('startNow', function() { if ($scope.startNow && $scope.repository && !$scope.uploading && !$scope.building) { diff --git a/static/partials/new-repo.html b/static/partials/new-repo.html index f452f3edb..4836576a8 100644 --- a/static/partials/new-repo.html +++ b/static/partials/new-repo.html @@ -143,9 +143,9 @@
Upload DockerfileArchive
-
+ is-ready="hasDockerfile" uploading="uploading" building="building">
From ca350f98081d1675ac57c52fdbe8bd2b26bdbfe1 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 16 Jan 2015 17:06:20 -0500 Subject: [PATCH 5/5] Better styling for the updated build dialog. This is temporary until we redo the UI --- static/css/quay.css | 13 +++++++++++++ static/directives/dockerfile-build-form.html | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/static/css/quay.css b/static/css/quay.css index 0f7a8be9c..ba5d0ea90 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -4912,4 +4912,17 @@ i.slack-icon { .dockerfile-build-form table td { vertical-align: top; + white-space: nowrap; } + +.dockerfile-build-form input[type="file"] { + margin: 0px; +} + +.dockerfile-build-form .help-text { + font-size: 13px; + color: #aaa; + margin-bottom: 20px; + padding-left: 22px; +} + diff --git a/static/directives/dockerfile-build-form.html b/static/directives/dockerfile-build-form.html index 5c5b1e37d..4dfba4e08 100644 --- a/static/directives/dockerfile-build-form.html +++ b/static/directives/dockerfile-build-form.html @@ -13,9 +13,15 @@
- + + + + +
Dockerfile or Archive (.tar.gz or .zip):Dockerfile or .tar.gz or .zip:
+
If an archive, the Dockerfile must be at the root
+
Base Image Pull Credentials: