fix(stacks): show missing status stacks (#5047)

Co-authored-by: dbuduev <dbuduev@gmail.com>
pull/5143/head
Chaim Lev-Ari 2021-06-14 15:40:00 +03:00 committed by GitHub
parent a5e8cf62d2
commit d7bc4f9b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -50,7 +50,7 @@ angular.module('portainer.app').controller('StacksDatatableController', [
if (stack.Orphaned) {
return stack.OrphanedRunning || this.settings.allOrphanedStacks;
} else {
return (stack.Status === 1 && showActiveStacks) || (stack.Status === 2 && showUnactiveStacks) || stack.External;
return (stack.Status === 1 && showActiveStacks) || (stack.Status === 2 && showUnactiveStacks) || stack.External || !stack.Status;
}
}

View File

@ -302,7 +302,7 @@ angular.module('portainer.app').controller('StackController', [
$scope.formValues.Env = $scope.stack.Env;
let resourcesPromise = Promise.resolve({});
if (stack.Status === 1) {
if (!stack.Status || stack.Status === 1) {
resourcesPromise = stack.Type === 1 ? retrieveSwarmStackResources(stack.Name, agentProxy) : retrieveComposeStackResources(stack.Name);
}
@ -312,9 +312,15 @@ angular.module('portainer.app').controller('StackController', [
});
})
.then(function success(data) {
const isSwarm = $scope.stack.Type === 1;
$scope.stackFileContent = data.stackFile;
// workaround for missing status, if stack has resources, set the status to 1 (active), otherwise to 2 (inactive) (https://github.com/portainer/portainer/issues/4422)
if (!$scope.stack.Status) {
$scope.stack.Status = data.resources && ((isSwarm && data.resources.services.length) || data.resources.containers.length) ? 1 : 2;
}
if ($scope.stack.Status === 1) {
if ($scope.stack.Type === 1) {
if (isSwarm) {
assignSwarmStackResources(data.resources, agentProxy);
} else {
assignComposeStackResources(data.resources);