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

fix nasty edge case where we can't find guest additions on windows if they are on a different drive #5761

Merged
merged 11 commits into from
Jan 11, 2018

Conversation

SwampDragons
Copy link
Contributor

@SwampDragons SwampDragons commented Jan 3, 2018

fixes #5713
fixes #5700

See the gloriously detailed comment here for context: #5713 (comment)

I've tested this on osx, as well as on windows both on the same and on a different drive. I've confirmed that this fixes the issue reported in 5713, and it doesn't seem to break anything else. Would love some sanity-check confirmation from other windows users that this has fixed things.

@SwampDragons SwampDragons requested a review from a team as a code owner January 3, 2018 23:41
@SwampDragons
Copy link
Contributor Author

looking into test failures, and seeing wether I can add a few more filepath tests to DownloadableURL

@arizvisa
Copy link
Contributor

arizvisa commented Jan 4, 2018

Don't forget to include UNC paths in the testcases that are prefixed with a double-backslash. Some of us Windows people desire that too.

@arizvisa
Copy link
Contributor

arizvisa commented Jan 4, 2018

I mean, or you could just give a code review to that PR i submitted like forever ago...

@SwampDragons
Copy link
Contributor Author

@arizvisa

Reviewed. If you wanna work with me on this please let me know.

@arizvisa
Copy link
Contributor

arizvisa commented Jan 9, 2018

Hey, just realized what you're working on adding with this PR and maybe this will help with conversions, but in my GH-2377 branch that I submitted a PR for, I added an interface to downloader called "LocalDownloader" which exposes a .toPath() method for converting a busted windows-url to a local path.

You can see the different cases that I handled at : https://github.com/arizvisa/packer/blob/GH-2377/common/download.go#L361, so if you're trying to verify that the url is actually something valid that can be used, then maybe that .toPath() method can be copied or exposed somehow(?)

@SwampDragons
Copy link
Contributor Author

SwampDragons commented Jan 9, 2018

oh, nice. I'll take a look.

@SwampDragons
Copy link
Contributor Author

@AndrewSav I've tested this branch on my windows vm and it appears to have cleared up your issue. Will you please sanity-check me and confirm that it isn't causing you trouble? I can create you a binary if you need it.

@AndrewSav
Copy link

@SwampDragons, It can take up to 48 hours. A binary would be appreciated as it would speed things up a bit.

@SwampDragons
Copy link
Contributor Author

packer.zip
Windows build of this branch ^^

@mwhooker mwhooker changed the title fix nasty edge case where we can't find guest additions on windows if… fix nasty edge case where we can't find guest additions on windows if they are on a different drive Jan 10, 2018
@andrewsav-bt
Copy link

@SwampDragons testing it now. a tar without extension in the zip gave me a pause but I figured that out.

@andrewsav-bt
Copy link

@SwampDragons it seems to be working, thank you for the fix. I just tested my test case from the original issue, I cannot vouch if the fix did not break something else ;)

@SwampDragons
Copy link
Contributor Author

@AndrewSav Glad to hear it.

errs = packer.MultiErrorAppend(errs,
fmt.Errorf("source file needs to exist at time of config validation: %s", err))
}
_, err := common.FileExistsLocally(c.SourcePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

since the first parameter isn't used, I feel like this should be rewritten to something like

func ValidateFileExistence(string) bool

and just return true or false

So instead of saying "return a 2x2 result matrix and we'll decide what to do", we can just wrap all our business logic in a yes/no answer.

You could also have it return an error instead of a bool if you feel the error from stat is useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh I like this. you're completely right; as used right now I really want a simple yes or no answer.

@mwhooker
Copy link
Contributor

left a comment/advice. feel free to take it or not. lgtm

@SwampDragons SwampDragons merged commit fb730cf into master Jan 11, 2018
arizvisa added a commit to arizvisa/hashicorp-packer that referenced this pull request Jan 19, 2018
…URL policies made by the PR hashicorp#5761 merge.

common/config.go:
    Added the ability for DownloadableURL to promote UNC paths to the SMB uri.
    Modified DownloadableURL to include the "./" prefix when a relative path is passed to it.
    Fix-up the DownloadableURL argument if on windows and incorrectly prefixed with "/".
arizvisa added a commit to arizvisa/hashicorp-packer that referenced this pull request Jan 19, 2018
…g to disk on the windows platform. Also added tests for relative paths/uris.

common/config_test.go:
    Replaced instances of os.Mkdir and os.Create with tests that use
        the existing "common/test-fixtures" mechanism.
    Removed the runtime.GOOS test for the "FileExistsLocally" test,
        as the functionality should work regardless of the platform.
    Added some more comprehensive tests for the relative uri/pathing.
    Replaced the Windows Object Manager name test as the Object
        Manager's naming scheme is different from a UNC path.
    Modified the FilePaths tests to support the policy of windows absolute
        paths being prefixed with the `/` introduced with PR hashicorp#5761.
@SwampDragons SwampDragons modified the milestones: v1.1.4, v1.2.0 Jan 30, 2018
@SwampDragons SwampDragons deleted the fix_5713 branch February 21, 2018 22:32
@bstoots
Copy link

bstoots commented Nov 12, 2018

Is this change included in the latest 1.3.2 release? I'm still encountering this issue and want to know if I should file a separate issue or not.

@SwampDragons
Copy link
Contributor Author

Please do open a new issue! This was merged several releases ago, so if you're seeing something similar it's new/different/has been reintroduced.

@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants