diff --git a/app/portainer/components/datatables/stacks-datatable/stacksDatatableController.js b/app/portainer/components/datatables/stacks-datatable/stacksDatatableController.js index 86d24020d..b96089f29 100644 --- a/app/portainer/components/datatables/stacks-datatable/stacksDatatableController.js +++ b/app/portainer/components/datatables/stacks-datatable/stacksDatatableController.js @@ -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; } } diff --git a/app/portainer/views/stacks/edit/stackController.js b/app/portainer/views/stacks/edit/stackController.js index ec865b9a3..9239f7644 100644 --- a/app/portainer/views/stacks/edit/stackController.js +++ b/app/portainer/views/stacks/edit/stackController.js @@ -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);