Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

Allow Directory Creation failures to continue for Service Account use scenarios that don't have home directories

addresses #3011

Copy link
Contributor

Choose a reason for hiding this comment

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

While extremely unlikely - this test could cause spurious failures, if for example a background process installed a new module between runs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think it would sufficient to just check it's greater than 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check can be removed - it would be redundantly checked in QueueSerialization and it will rarely be true, so the extra code isn't saving anything in the normal case.

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Mar 3, 2017

Choose a reason for hiding this comment

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

I considered this originally and perhaps over optimizing for avoiding a function call. I'll remove.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check can also be removed, though it wouldn't hurt to assert here.

The design is that nobody can call Serialize without going through QueueSerialization, so the check isn't needed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will remove and add assert

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't thought through the implications - but should we have a fallback? e.g. $env:TEMP?

Copy link
Member Author

Choose a reason for hiding this comment

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

This usage is an edge case, I'm not sure how much we want to optimize particularly as one can use the XDG_*_HOME env vars. Also, I don't think it's guaranteed the user account has write access to $env:TEMP so we'd have to check that anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

What sort of contract should this api have? If the directory can't be used, should this api return null instead?

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Mar 3, 2017

Choose a reason for hiding this comment

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

Path.Combine() is used often with this api and would have a problem with null. My thinking was that this api returns the expected path which may be used in error message, so even returning an empty string may produce undesired results.

… scenarios that don't have home directories

Removed redundant checks if saving to analysis cache
Updated test to avoid race condition where a module is added in between checks

addresses PowerShell#3011

Removed unnecessary check to save to disk
@lzybkr lzybkr merged commit a2687bf into PowerShell:master Mar 6, 2017
@SteveL-MSFT SteveL-MSFT deleted the serviceaccount branch March 21, 2017 19:53
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