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

udisks2: Be more tolerant of device-startup time #1359

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

sjg20
Copy link
Contributor

@sjg20 sjg20 commented Apr 11, 2024

When switching an SDWire to 'host' mode, it may take time for the partition to appear.

During that time the device (e.g. '/dev/sdo1') may not exist, so trying to cat e.g. '/sys/call/block/sdo1' fails. Handle this by returning a zero size in that case, as is done when the returned size is empty.

Even when the block device is present, udisks2 may take a short time to make the device available. Handle this by retrying a few times, until things settle.

Add the call to _wait_for_medium() in write_files() while we are here, to match what is done in write_image(). Also fix the parameter type for write_files() and mention the exception it may raise.

This change has been manually tested since there are no tests available for the code being modified.

Checklist

  • Documentation for the feature
  • Tests for the feature
    (I cannot find any tests for USBStorage)
  • The arguments and description in doc/configuration.rst have been updated
    (not needed, I think)
    --->
  • PR has been tested
  • Man pages have been regenerated
    (it seems that these were out-of-sync before my PR)

Fixes: #1357

@Bastian-Krause
Copy link
Member

@a3f Could you take a look at this?

Copy link
Contributor

@a3f a3f left a comment

Choose a reason for hiding this comment

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

LGTM apart from the two comments.

labgrid/util/agents/udisks2.py Outdated Show resolved Hide resolved
labgrid/util/agents/udisks2.py Show resolved Hide resolved
When switching an SDWire to 'host' mode, it may take time for the
partition to appear.

During that time the device (e.g. '/dev/sdo1') may not exist, so trying
to cat e.g. '/sys/call/block/sdo1' fails. Handle this by returning a
zero size in that case, as is done when the returned size is empty.

Even when the block device is present, udisks2 may take a short time to
make the device available. Handle this by retrying a few times, until
things settle.

Add the call to _wait_for_medium() in write_files() while we are here,
to match what is done in write_image(). Also fix the parameter type for
write_files() and mention the exception it may raise.

Fixes: labgrid-project#1357

Signed-off-by: Simon Glass <[email protected]>
@sjg20
Copy link
Contributor Author

sjg20 commented Apr 28, 2024

LGTM apart from the two comments.

OK, I addressed one and explained the other

Emantor
Emantor previously approved these changes May 2, 2024
@Emantor Emantor requested a review from a3f May 2, 2024 09:30
Copy link
Member

@Bastian-Krause Bastian-Krause left a comment

Choose a reason for hiding this comment

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

@Emantor Please don't merge this, yet. I'd like to look into this. I suspect the retry mechanism can be implemented more straight forward.

@Bastian-Krause Bastian-Krause self-assigned this May 2, 2024
@Emantor Emantor dismissed their stale review May 2, 2024 19:42

Outstanding changes from @Bastian-Krause

@sjg20
Copy link
Contributor Author

sjg20 commented May 22, 2024

@Emantor Please don't merge this, yet. I'd like to look into this. I suspect the retry mechanism can be implemented more straight forward.

Any word on when you will figure this out? I am able to test things if it helps

@Emantor Emantor merged commit 9c5034a into labgrid-project:master Jun 26, 2024
9 checks passed
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.

No udisks2 device found for /dev/sdo1
4 participants