diff --git a/buildman/component/buildcomponent.py b/buildman/component/buildcomponent.py index 1d3ee078b..ffbe36a2b 100644 --- a/buildman/component/buildcomponent.py +++ b/buildman/component/buildcomponent.py @@ -206,10 +206,10 @@ class BuildComponent(BaseComponent): self._last_heartbeat = datetime.datetime.utcnow() # Parse any of the JSON data logged. - docker_data = {} + log_data = {} if json_data: try: - docker_data = json.loads(json_data) + log_data = json.loads(json_data) except ValueError: pass @@ -217,8 +217,8 @@ class BuildComponent(BaseComponent): fully_unwrapped = '' keys_to_extract = ['error', 'status', 'stream'] for key in keys_to_extract: - if key in docker_data: - fully_unwrapped = docker_data[key] + if key in log_data: + fully_unwrapped = log_data[key] break # Determine if this is a step string. @@ -233,10 +233,10 @@ class BuildComponent(BaseComponent): # Parse and update the phase and the status_dict. The status dictionary contains # the pull/push progress, as well as the current step index. with self._build_status as status_dict: - if self._build_status.set_phase(phase): + if self._build_status.set_phase(phase, log_data.get('status_data')): logger.debug('Build %s has entered a new phase: %s', self.builder_realm, phase) - BuildComponent._process_pushpull_status(status_dict, phase, docker_data, self._image_info) + BuildComponent._process_pushpull_status(status_dict, phase, log_data, self._image_info) # If the current message represents the beginning of a new step, then update the # current command index. @@ -244,8 +244,8 @@ class BuildComponent(BaseComponent): status_dict['current_command'] = current_step # If the json data contains an error, then something went wrong with a push or pull. - if 'error' in docker_data: - self._build_status.set_error(docker_data['error']) + if 'error' in log_data: + self._build_status.set_error(log_data['error']) if current_step is not None: self._build_status.set_command(current_status_string) diff --git a/static/directives/build-log-error.html b/static/directives/build-log-error.html index af7659a08..db5c81eae 100644 --- a/static/directives/build-log-error.html +++ b/static/directives/build-log-error.html @@ -1,22 +1,21 @@
+ - - - caused by attempting to pull private repository {{ getLocalPullInfo().repo }} - with inaccessible credentials - without credentials + + + + Error 403: Could not pull private base image {{ localPullInfo.repo }} without robot account credentials. Please see + Setting up build trigger credentials for more information. + + + Error 403: Could not pull private base image {{ localPullInfo.repo }} because robot account {{ localPullInfo.username}} does not have access. Please see + Setting up build trigger credentials for more information. + - -
-
- Note: The credentials {{ getLocalPullInfo().login.username }} for registry {{ getLocalPullInfo().login.registry }} cannot - access repository {{ getLocalPullInfo().repo }}. -
-
- Note: No robot account is specified for this build. Without such credentials, this pull will always fail. Please setup a new - build trigger with a robot account that has access to {{ getLocalPullInfo().repo }} or make that repository public. -
-
+ + +
diff --git a/static/js/directives/ui/build-log-error.js b/static/js/directives/ui/build-log-error.js index c748cd597..a18d4b52f 100644 --- a/static/js/directives/ui/build-log-error.js +++ b/static/js/directives/ui/build-log-error.js @@ -13,16 +13,9 @@ angular.module('quay').directive('buildLogError', function () { 'entries': '=entries' }, controller: function($scope, $element, Config) { - $scope.isInternalError = function() { - var entry = $scope.entries[$scope.entries.length - 1]; - return entry && entry.data && entry.data['internal_error']; - }; - - $scope.getLocalPullInfo = function() { - if ($scope.entries.__localpull !== undefined) { - return $scope.entries.__localpull; - } + $scope.localPullInfo = null; + var calculateLocalPullInfo = function(entries) { var localInfo = { 'isLocal': false }; @@ -32,29 +25,32 @@ angular.module('quay').directive('buildLogError', function () { for (var i = 0; i < $scope.entries.length; ++i) { var entry = $scope.entries[i]; if (entry.type == 'phase' && entry.message == 'pulling') { - for (var j = 0; j < entry.logs.length(); ++j) { - var log = entry.logs.get(j); - if (log.data && log.data.phasestep == 'login') { - localInfo['login'] = log.data; - } - - if (log.data && log.data.phasestep == 'pull') { - var repo_url = log.data['repo_url']; - var repo_and_tag = repo_url.substring(Config.SERVER_HOSTNAME.length + 1); - var tagIndex = repo_and_tag.lastIndexOf(':'); - var repo = repo_and_tag.substring(0, tagIndex); - - localInfo['repo_url'] = repo_url; - localInfo['repo'] = repo; - - localInfo['isLocal'] = repo_url.indexOf(Config.SERVER_HOSTNAME + '/') == 0; - } + var entryData = entry.data || {}; + if (entryData.base_image) { + localInfo['isLocal'] = true || entryData['base_image'].indexOf(Config.SERVER_HOSTNAME + '/') == 0; + localInfo['pullUsername'] = entryData['pull_username']; + localInfo['repo'] = entryData['base_image'].substring(Config.SERVER_HOSTNAME.length); } break; } } - return $scope.entries.__localpull = localInfo; + $scope.localPullInfo = localInfo; + }; + + calculateLocalPullInfo($scope.entries); + + $scope.isInternalError = function() { + var entry = $scope.entries[$scope.entries.length - 1]; + return entry && entry.data && entry.data['internal_error']; + }; + + $scope.isPullError = function(error) { + if (!error || !error.data || !error.data.base_error) { + return false; + } + + return error.data.base_error.indexOf('Error: Status 403 trying to pull repository ') == 0; }; } };