Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support creating stacks with the same name across different endpoints #1347

Closed
zhaoyao91 opened this issue Nov 2, 2017 · 17 comments · Fixed by #4520
Closed

Support creating stacks with the same name across different endpoints #1347

zhaoyao91 opened this issue Nov 2, 2017 · 17 comments · Fixed by #4520
Labels
area/stacks kind/enhancement Applied to Feature Requests
Milestone

Comments

@zhaoyao91
Copy link

Description

I use portainer 1.15.0 to manage two endpoints. I cannot create two stacks with same name even in different endpoints.

Steps to reproduce the issue:

  1. create a stack named 'test' in endpoint 1
  2. try to create a stack named 'test' in endpoint 2
  3. it errors: stack already exists with this name
@deviantony
Copy link
Member

Yes, this is by design in order to ensure uniqueness for each stacks.

I.e, currently Portainer uses the stack name to create UAC on related resources (services, containers), so the name of the stack needs to be unique within the whole Portainer instance.

@zhaoyao91
Copy link
Author

For our usage, each endpoint is a different cluster and environment. So you suggest I start dedicated portainer for each cluster?

@ncresswell
Copy link
Member

ncresswell commented Nov 2, 2017 via email

@deviantony
Copy link
Member

@zhaoyao91 you could prefix/suffix the stack name with the environment name, e.g. '-dev', '-qa'...

@ncresswell I'll re-open and investigate if we can do something here.

@deviantony deviantony reopened this Nov 2, 2017
@deviantony deviantony added area/stacks kind/enhancement Applied to Feature Requests labels Nov 2, 2017
@zhaoyao91
Copy link
Author

zhaoyao91 commented Nov 2, 2017

Prefix stack name is not a good workaround since each component should not know that it's in some environment. I will use different portainer instances to hold on for some time. Look forward to good news :)

@deviantony
Copy link
Member

This was just an example, you just to need to create unique stack names. I understand the point tho and will investigate.

@WTFKr0
Copy link
Contributor

WTFKr0 commented Nov 2, 2017

Don't you add the swarmID for that purpose ?
If the two endpoints are not in same cluster, the SwarmID should be different
So the unicity should include that swarmID

I think the unicity check here can be done on stack ID instead of stack name :

for _, stack := range stacks {
if strings.EqualFold(stack.Name, stackName) {
httperror.WriteErrorResponse(w, portainer.ErrStackAlreadyExists, http.StatusConflict, handler.Logger)
return
}
}

@deviantony
Copy link
Member

deviantony commented Nov 2, 2017

Yes, this was added in order to ensure uniqueness within Portainer. But when you retrieve services/containers associated to a stack, the only reference for that stack is the name of the stack in the com.docker.stack.namespace label.

When we store the UAC of a stack, we also use the stack name (tho we could use a combo of swarmID / stack name here) as the identifier associated to the resource control object.

At the moment, stack name + swarm ID is used to create a unique identifier. It was choose over stack name + endpoint ID because we should be able to retrieve the stacks of a cluster when connected to any node of the cluster (manager, worker...). If we used stack name + endpoint ID, then we would have only be able to lists the stacks available in the endpoint where they were created.

It'd be nice if containers/services would include the ID of the associated Swarm in the labels, but this is not avaible at the moment. I wonder if we could add this into Docker?

Edit: I believe this would need to be added in the swarmkit project as well as the moby project:

@deviantony
Copy link
Member

Opened an issue in moby to be able to retrieve Swarm identifier from labels: moby/moby#36231

@fopina
Copy link

fopina commented Jan 5, 2020

just bumped into this issue. is it still not possible to allow stacks with same names in different endpoints? isn't the uniqueness given by other attributes yet?

@arturslogins
Copy link

For me this is actual too :/

@yunfandev
Copy link
Contributor

We also encountered this problem, when will it be fixed?

@RFBomb
Copy link

RFBomb commented May 24, 2020

Just ran into this issue.
I originally had 3 stack set up, but I was migrating to a new system.

A RasPi3 running portainer has endpoints for a RasPi4 and a NAS server. I was migrating my stacks from the RasPi4 to the NAS, so for a short period of a couple hours I had 3 'end points' on my portainer instance. Once I migrated all the stacks over, I removed the endpoint for the Raspi4. So now I only have the Pi-3 and the NAS server as endpoints.

Trouble is, even though I removed the end point, I cannot use any stack named that were originally in that end point. To compound the issue, and since there doesn't seem to be a way to restore an end point, I have no way to delete the memory of those stack names, meaning they are forever forbidden it seems.

This really should be fixed, or atleast open up a way to manually clear them out for situations like mine.

@soletan
Copy link

soletan commented Jun 17, 2020

Sorry for adding another same-here-post. But when in swarm context, a single portainer GUI is meant to be installed in that swarm, isn't it? In that case I only interact with that single portainer GUI which is meant to collect information from configured endpoints.

I am not familiar with other setups, for sure, but when using one swarm's portainer for accessing a remote swarm's resources using an edge agent I don't see the problem in relying on stack name + endpoint ID for uniquely identifying services of a stack. Even listing those in UI ain't no issue for I can't list stacks or services of multiple endpoints simultaneously, can I? Without selecting an endpoint there is no opportunity for showing resources bound to particular endpoints.

In my case this issue is limiting portainer's usability to manage and expose clusters of different customers in a single GUI for I can't stick to a similar pattern for setting up either customer's cluster.

@deviantony deviantony changed the title Cannot create stacks with same name in different endpoints Support creating stacks with the same name across different endpoints Oct 15, 2020
@joonas-fi
Copy link

This has been very painful for me. Portainer supports multiple endpoints, i.e. many different clusters. IMO each separate cluster should be its freestanding entity - other clusters internal state should not impose limits on other clusters. Now it does.

Background: I use immutable infrastructure pattern to manage my servers, i.e. I set up a new cluster and migrate my services into the new one, then remove that old one. I've to increase stack name numbers just to migrate my services. It's a royal pain, and that effectively makes my stack names dynamic, i.e. if I need to, I can't rely on hardcoding stack name anywhere.

@deviantony
Copy link
Member

Just an update on that topic, we have an implementation ready for this that is currently under testing: #4520

@deviantony deviantony added this to the 2.4.0 milestone Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/stacks kind/enhancement Applied to Feature Requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants