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

win_partition - Fix handling of maximum partition size #58225

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@chopraaa
Copy link
Contributor

commented Jun 22, 2019

SUMMARY

Fixes #56910

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

win_partition

ADDITIONAL INFORMATION

Doesn't resize the partition if the difference is ~1MiB +/- from the original partition size according to my post here: #56910 (comment) This issue is prevalent in partitions with large disk sizes so it's still not covered by these integration tests.

I've also removed -UseMaximumSize and specified the maximum supported size directly.

chopraaa added some commits Jun 22, 2019

@ansibot

This comment has been minimized.

@ShachafGoldstein

This comment has been minimized.

Copy link
Contributor

commented Jun 22, 2019

Any way to test the 1mb issue in the ci?
and, maybe use 1MB and not the actual length in the if since powershell translates it and it will be more readable.

another question for the crowd, should the module send out a warning when this issue occurs?

@ansibot ansibot removed the needs_triage label Jun 22, 2019

@chopraaa

This comment has been minimized.

Copy link
Contributor Author

commented Jun 22, 2019

Any way to test the 1mb issue in the ci?

I'm not sure about the free space available on the server at the time of testing. I think at the time of writing this, I kept the 1 GB partition for the sake of the CI so I'm not sure how much space is OK for us to use.

and, maybe use 1MB and not the actual length in the if since powershell translates it and it will be more readable.

I kept it in bytes to reduce conversions but I can do this is needed too.

another question for the crowd, should the module send out a warning when this issue occurs?

It would throw a warning most of the time though, making users think something is wrong with it. Not sure how to approach this either - perhaps a note in the docs?

@ShachafGoldstein

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

If you'll run Measure-Command {1MB} you can see the conversion is not an issue

@chopraaa

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

I'm probably wrong but it seems like the way of doing this would be to replace:

($ansible_partition_size - $ansible_partition.Size -gt 1049000 -or $ansible_partition.Size - $ansible_partition_size -gt 1049000)

with:

([Math]::Round(($ansible_partition_size - $ansible_partition.Size)/1MB) -le 1 -or [Math]::Round(($ansible_partition.Size - $ansible_partition_size)/1MB) -le 1)

Or is there another way of doing this seeing how direct conversion to MiB isn't possible?

@ShachafGoldstein

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2019

@chopraaa

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2019

It must be less than 1 MiB not 1 MB though.

@ansibot ansibot added the stale_ci label Jul 2, 2019

@branic

This comment has been minimized.

Copy link

commented Jul 5, 2019

You could simplify the if statement and math by doing:

[Math]::Abs(($ansible_partition_size - $ansible_partition.Size)/1024/1024) -gt 1

The 1024/1024 could be replaced by 1048576 (or 104900), but to me the 1024/1024 is clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.