Record phase information and make better error messages on pull failure
This commit is contained in:
parent
d9ce8fdf52
commit
e06435fee4
3 changed files with 46 additions and 51 deletions
|
@ -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;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue