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

helper/ssh: add random number to upload path for script [GH-1545] #1588

Merged
merged 1 commit into from
Apr 20, 2015

Conversation

mitchellh
Copy link
Contributor

Fixes #1545

This makes the default remote path include a random number. There are no backwards incompatibilities here. It was an edge case found by #1545 that if you have multiple remote-exec in parallel (possible by targeting other remote hosts from multiple resources), then the scripts would collide.

@@ -25,7 +28,7 @@ const (

// DefaultScriptPath is used as the path to copy the file to
// for remote execution if not provided otherwise.
DefaultScriptPath = "/tmp/script.sh"
DefaultScriptPath = "/tmp/script_%RAND%.sh"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of weird but I've decided not to document this since it is a very advanced use case. And it looks like most people don't use this arg anyways. I'd rather not promise any backwards compat on the syntax of this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed +1

return strings.Replace(
c.ScriptPath, "%RAND%",
strconv.FormatInt(int64(rand.Int31()), 10), -1)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a bit of potential for future confusion that this isn't memoized, but this area of the code is simple enough that I think it's not a big deal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, yeah. I think it'll be okay to get started though.

@phinze
Copy link
Contributor

phinze commented Apr 20, 2015

Yep yep this looks good. 👍

mitchellh added a commit that referenced this pull request Apr 20, 2015
helper/ssh: add random number to upload path for script [GH-1545]
@mitchellh mitchellh merged commit ccd14a6 into master Apr 20, 2015
@mitchellh mitchellh deleted the b-par-prov branch April 20, 2015 17:22
@phinze phinze mentioned this pull request Apr 27, 2015
@ghost
Copy link

ghost commented May 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple remote-exec's against the same target overwrite script.sh
2 participants