Skip to content

Conversation

@martijnvans
Copy link
Contributor

Description

RunScriptRemotely() has had a bug for a long time that nobody has ever triggered if it is called multiple times concurrently on the same VM. This PR fixes the bug before anybody runs into it.

Related issue

none

How has this been tested?

automated tests should be enough.

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

if err := UploadContent(ctx, logger, vm, strings.NewReader(scriptContents), "C:\\temp.ps1"); err != nil {
// Use a UUID for the script name in case RunScriptRemotely is being
// called concurrently on the same VM.
scriptPath := "C:\\"+uuid.NewString()+".ps1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just one comment about using uuid.NewString() for the path. Are all possible characters from a uuid string valid for a Windows filename ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just lowercase 0-9a-f plus hyphens, shold be OK. Plus it (mostly) pasesd tests.

@martijnvans martijnvans merged commit 6d8594e into master Jan 27, 2023
@martijnvans martijnvans deleted the martijnvans-script-uuiid branch January 27, 2023 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants