Closed Maxim-Filimonov closed 9 years ago
hrmm this sounds like a bug! Thanks for the report… we'll investigate.
This actually used to be the behaviour. We used to append -1 -2 etc if there was already an agent by that name. But I removed it because if you typed buildkite-agent start --name test
it was weird for us to just change the name on you "but I called my agent test, not test-1". And there isn't a way to change the name after the fact.
So under the old way:
^ That happened to me and it was a PITA. So I figured it was better to be less magical at the moment. What do you think?
For what it's worth, I used explicit --name
flags and have had no overlap in build folders.
@underscorediscovery I do the same now but it's a bit manual. How about is there is a flag --autoname which brings the magic back?
Btw while we are no this topic. Would be nice to see an example of upstart for multiple agents. I'm struggling to make existing upstart to work with multiple agents :\
I agree that explicit naming is by nature not "elastic", mainly I was noting for debugging/validation purposes. I think an auto naming option would be ideal.
When it comes to user action, if I explicitly set two agents to the same name using --name it's my fault, maybe the second explicitly named one can error because one is already running on that machine.
perhaps explicit naming doesn't add -1, -2, etc… but implicit naming does.
Perhaps it's better to be safe, and have them namespaced, even if it means it can be slightly annoying to get the exact name you want if you're running multiple agents?
@toolmantim sounds like that would be the best option. It can fail on implicit naming if there is an agent with the same name from the same host And in case of implicit naming it can just add -1, -2. Or you can use some name generator to just create a random name for an agent
The more I think about this, the more I just want the -1, -2, -3 naming at all times. Say I wanted to easily spin up 3 new agents:
$ buildkite-agent start --name fancy-agent &
$ buildkite-agent start --name fancy-agent &
$ buildkite-agent start --name fancy-agent &
Name is just a label, you don't target it at all… so I'd prefer not to error on setting a label. Just add -1, -2, -3. It's purely aesthetic, so no need to make someone's life harder. Especially if the workaround is just killing existing agents.
I say we just revert to the old behaviour.
I wouldn't say the name is aesthetic only as it affects the predictable-by-name build path location. This has implications as new names require completely new checkouts, can't be relied upon for local scripting (maybe there is an env var, but the path might not be running through the build agent, it could be a cronjob for instance) and various other things. Just noting its not for the dashboard only.
I agree that it should be simple and straight forward, so that makes sense to just append a counter if you're doing the name that way.
Maybe a good option is to - upon firing up an agent -
print the name of existing agents running (* = new one)
-fancy-agent
-fancy-agent-1
-*fancy-agent-2
This might catch those times you accidentally fire up 2 or more by accident perhaps.
I just thought I'd share with you something I just pushed to production that may help here! Note, it's prety experimental, and I'm just throwing it out there for feedback. If it's no good, we may rip it out.
Firstly, If you update to 1.0-beta.19
, we start reporting the name as returned from Buildkite (so the name in the console output is exactly the same as it would appear in the agent list).
Next thing, if you specify an agent name with a "%n" in it, the "%n" will be substituted with how many of those agents are currently online that match that name. So I ran this 10 times in parallel:
$ buildkite-agent start --token xxx --name "best-ever-%n"
And this was the result:
I think this is a good compromise! That means you can have what ever format you want, and if you tell Buildkite to name something "x", we're not just going to change it on you (if we did the automatic -1
gear). Also some people's naming scheme may not use the dash syntax (they may use underscores or capital letters, etc).
Looks good!
@keithpitt LGTM! :+1:
Going to close this now, as I think everyones :smile: :dancers: Thanks for your help guys!
With new elastic agent automatic naming seems to only use ip address. Which makes multiple agents running from the same machine use the same base folder. Maybe if the agent is from the same machine it's hostname can be postfixed with a number something like first-agent: 192.168.1.25 second-agent: 192.168.1.25-2