From 73950f360342e103103c50483fad1c267f6a6b12 Mon Sep 17 00:00:00 2001 From: LP B Date: Wed, 7 Jun 2023 14:28:40 +0200 Subject: [PATCH] fix(app/stacks): swarm stack duplicate and migrate errors [EE-5520] (#9039) * fix(dev): dev container script * fix(app/stacks): make swarm stack migrate effectively target the target env and not the current env * fix(app/stacks): make stack duplicate save the target swarm id on duplicated swarm stack --- app/docker/services/swarmService.js | 4 ++-- app/portainer/services/api/stackService.js | 4 ++-- dev/run_container.sh | 25 +++++++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/docker/services/swarmService.js b/app/docker/services/swarmService.js index 9ad18d212..5fa7da6c2 100644 --- a/app/docker/services/swarmService.js +++ b/app/docker/services/swarmService.js @@ -7,10 +7,10 @@ angular.module('portainer.docker').factory('SwarmService', [ 'use strict'; var service = {}; - service.swarm = function () { + service.swarm = function (endpointId) { var deferred = $q.defer(); - Swarm.get() + Swarm.get(endpointId ? { endpointId } : undefined) .$promise.then(function success(data) { var swarm = new SwarmViewModel(data); deferred.resolve(swarm); diff --git a/app/portainer/services/api/stackService.js b/app/portainer/services/api/stackService.js index 0532cf598..80d3bd11e 100644 --- a/app/portainer/services/api/stackService.js +++ b/app/portainer/services/api/stackService.js @@ -50,7 +50,7 @@ angular.module('portainer.app').factory('StackService', [ service.migrateSwarmStack = function (stack, targetEndpointId, newName) { var deferred = $q.defer(); - SwarmService.swarm() + SwarmService.swarm(targetEndpointId) .then(function success(data) { var swarm = data; if (swarm.Id === stack.SwarmId) { @@ -324,7 +324,7 @@ angular.module('portainer.app').factory('StackService', [ service.createSwarmStackFromFileContent = function (name, stackFileContent, env, endpointId) { var deferred = $q.defer(); - SwarmService.swarm() + SwarmService.swarm(endpointId) .then(function success(swarm) { var payload = { Name: name, diff --git a/dev/run_container.sh b/dev/run_container.sh index 09990897e..56b00edd4 100755 --- a/dev/run_container.sh +++ b/dev/run_container.sh @@ -5,18 +5,17 @@ PORTAINER_DATA=${PORTAINER_DATA:-/tmp/portainer} PORTAINER_PROJECT=${PORTAINER_PROJECT:-$(pwd)} PORTAINER_FLAGS=${PORTAINER_FLAGS:-} -docker rm -f portainer > /dev/null +docker rm -f portainer docker run -d \ --p 8000:8000 \ --p 9000:9000 \ --p 9443:9443 \ --v "$PORTAINER_PROJECT/dist:/app" \ --v "$PORTAINER_DATA:/data" \ --v /var/run/docker.sock:/var/run/docker.sock:z \ --v /var/run/docker.sock:/var/run/alternative.sock:z \ --v /tmp:/tmp \ ---name portainer \ ---rm \ -portainer/base \ -/app/portainer ${PORTAINER_FLAGS} + -p 8000:8000 \ + -p 9000:9000 \ + -p 9443:9443 \ + -v "$PORTAINER_PROJECT/dist:/app" \ + -v "$PORTAINER_DATA:/data" \ + -v /var/run/docker.sock:/var/run/docker.sock:z \ + -v /var/run/docker.sock:/var/run/alternative.sock:z \ + -v /tmp:/tmp \ + --name portainer \ + portainer/base \ + /app/portainer $PORTAINER_FLAGS