Merge lp://staging/~gesha/linaro-image-tools/717129 into lp://staging/linaro-image-tools/11.11
Proposed by
Georgy Redkozubov
Status: | Merged |
---|---|
Approved by: | Mattias Backman |
Approved revision: | 476 |
Merged at revision: | 479 |
Proposed branch: | lp://staging/~gesha/linaro-image-tools/717129 |
Merge into: | lp://staging/linaro-image-tools/11.11 |
Diff against target: |
171 lines (+107/-8) 2 files modified
linaro_image_tools/media_create/partitions.py (+39/-8) linaro_image_tools/media_create/tests/test_media_create.py (+68/-0) |
To merge this branch: | bzr merge lp://staging/~gesha/linaro-image-tools/717129 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mattias Backman (community) | Approve | ||
Georgy Redkozubov | Pending | ||
Review via email: mp+85478@code.staging.launchpad.net |
This proposal supersedes a proposal from 2011-12-08.
Description of the change
This branch adds the ability to check for appearance of partitions to the UDisks service for the device being partitioned.
media_create looks in a loop for the devices if they are not found it sleeps for 1 second, then looks again, increases sleep time by 1 second, checks and sleeps again until maximum number of sleep attempts is reached or devices appear. Now MAX_TTS is 10 so the maximum sleep time is 55 seconds.
To post a comment you must log in.
Hi Georgy,
I have a few comments below but what worries me is that the new code is
untested and if in the future somebody accidentally breaks it we might end up
causing unnecessary sleeps.
There's also the fact that we don't seem to have anybody who can reproduce the
issue anymore to confirm that these changes actually fix the issue.
On Thu, 2011-12-08 at 12:29 +0000, Georgy Redkozubov wrote: image_tools/ media_create/ partitions. py' image_tools/ media_create/ partitions. py 2011-07-28 01:24:21 +0000 image_tools/ media_create/ partitions. py 2011-12-08 12:29:00 +0000 p.DBus. Properties' p.UDisks"
[...]
> This branch adds the ability to check for appearance of partitions in /dev for the device being partitioned.
> media_create looks in a loop for the devices if they are not found it sleeps for 1 second, then looks again, increases sleep time by 1 second, checks and sleeps again until maximum number of sleep attempts is reached or devices appear. Now MAX_TTS is 10 so the maximum sleep time is 55 seconds.
> I couldn't reproduce the failures to find more nice fix. Please review and try.
> differences between files attachment (review-diff.txt)
> === modified file 'linaro_
> --- linaro_
> +++ linaro_
> @@ -24,6 +24,7 @@
> import re
> import subprocess
> import time
> +import sys
>
> import dbus
> from parted import (
> @@ -42,6 +43,7 @@
> CYLINDER_SIZE = HEADS * SECTORS * SECTOR_SIZE
> DBUS_PROPERTIES = 'org.freedeskto
> UDISKS = "org.freedeskto
> +MAX_TTS = 10 # max number of attempts to sleep (total sleep time in seconds = 1+2+...+MAX_TTS)
You could move the comment to a line by itself to keep the lines under 80
characters.
> partitions( board_config, media, image_size, bootfs_label, align_boot_ part=should_ align_boot_ part) block_device: to_settle( media)
>
> def setup_android_
> @@ -142,6 +144,7 @@
> should_
>
> if media.is_
> +#!!!! wait_partition_
We can remove this now, right?
> bootfs, rootfs = get_boot_ and_root_ partitions_ for_media( /bugs.freedeskt op.org/ show_bug. cgi?id= 33113.
> media, board_config)
> # It looks like KDE somehow automounts the partitions after you
> @@ -428,6 +431,15 @@
> """
> # This could be simpler but UDisks doesn't make it easy for us:
> # https:/
> + tts = 1
> + while not glob.glob("%s?*" % device) and (tts <= MAX_TTS):
> + print "Sleeping for %s second(s) to wait for the partitions available" % tts
> + time.sleep(tts)
> + tts += 1
This looks very similar to wait_partition_ to_settle( ). Can't we reuse that
here? Maybe we could if we refactored it.
> + if tts > MAX_TTS: device_ path(dev_ file) ).get_object( UDISKS, device_path) to_settle( media) get_sfdisk_ cmd( align_boot_ part=should_ align_boot_ pa...
> + print "Error: Couldn't read partitions for a reasonable time."
> + sys.exit(1)
> +
> for dev_file in glob.glob("%s?*" % device):
> device_path = _get_udisks_
> udisks_dev = dbus.SystemBus(
> @@ -516,6 +528,8 @@
> ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True)
> proc.wait()
>
> + wait_partition_
> +
> sfdisk_cmd = board_config.
> should_