From dfce48cd5e561a81e73ee8a2f5ed3e0ed2d792ff Mon Sep 17 00:00:00 2001 From: matias-portainer <104775949+matias-portainer@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:12:43 -0300 Subject: [PATCH] fix(stacks): check properly if endpoint id is defined in the stacks object EE-6118 (#10302) --- .../applications/create/createApplicationController.js | 5 +++++ app/portainer/views/stacks/edit/stackController.js | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 495b151a8..2adcfcd79 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -1178,6 +1178,11 @@ class KubernetesCreateApplicationController { if (this.state.isEdit) { this.nodesLimits.excludesPods(this.application.Pods, this.formValues.CpuLimit, KubernetesResourceReservationHelper.bytesValue(this.formValues.MemoryLimit)); + + // Workaround for EE-6118 + if (this.stack && !this.stack.EndpointId) { + this.stack.EndpointId = this.endpoint.Id; + } } this.oldFormValues = angular.copy(this.formValues); diff --git a/app/portainer/views/stacks/edit/stackController.js b/app/portainer/views/stacks/edit/stackController.js index dd5850471..046aebd26 100644 --- a/app/portainer/views/stacks/edit/stackController.js +++ b/app/portainer/views/stacks/edit/stackController.js @@ -176,7 +176,7 @@ angular.module('portainer.app').controller('StackController', [ // The EndpointID property is not available for these stacks, we can pass // the current endpoint identifier as a part of the migrate request. It will be used if // the EndpointID property is not defined on the stack. - if (stack.EndpointId === 0) { + if (!stack.EndpointId) { stack.EndpointId = endpoint.Id; } @@ -248,7 +248,7 @@ angular.module('portainer.app').controller('StackController', [ // The EndpointID property is not available for these stacks, we can pass // the current endpoint identifier as a part of the update request. It will be used if // the EndpointID property is not defined on the stack. - if (stack.EndpointId === 0) { + if (!stack.EndpointId) { stack.EndpointId = endpoint.Id; } @@ -347,6 +347,11 @@ angular.module('portainer.app').controller('StackController', [ resourcesPromise = stack.Type === 1 ? retrieveSwarmStackResources(stack.Name, agentProxy) : retrieveComposeStackResources(stack.Name); } + // Workaround for EE-6118 + if (!stack.EndpointId) { + stack.EndpointId = endpoint.Id; + } + return $q.all({ stackFile: StackService.getStackFile(id), resources: resourcesPromise,