Fix NTFS SD card mount failure by adding sync and udevadm settle (BugFix)#1717
Fix NTFS SD card mount failure by adding sync and udevadm settle (BugFix)#1717fernando79513 merged 19 commits intocanonical:mainfrom
Conversation
Fix an issue where Checkbox aborts during the SDHC storage test due to a race
condition when mounting an NTFS-formatted SD card. The test fails with:
ntfs-3g-mount: mount failed: Device or resource busy
because `mount_usb_storage()` executes before Ubuntu's auto-mount process
completes.
Add `sync` to flush pending writes and `udevadm settle` to wait for udev events,
ensuring the device is ready before mounting.
Signed-off-by: Jeffery Yen <songpao226@gmail.com>
Co-authored-by: Wayne Lin <q123456462@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1717 +/- ##
==========================================
+ Coverage 49.12% 49.14% +0.02%
==========================================
Files 372 372
Lines 40338 40334 -4
Branches 6809 6810 +1
==========================================
+ Hits 19816 19824 +8
+ Misses 19799 19786 -13
- Partials 723 724 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fernando79513
left a comment
There was a problem hiding this comment.
Thank you very much for this PR!
It's really well documented and explained. I've just added a couple of comments.
The main issue is that I think you have to validate your gpg keys. That will fix the issue with the deb validator and with the merge of the PR.
checkbox-support/checkbox_support/scripts/tests/test_mount_usb_storage.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_mount_usb_storage.py
Outdated
Show resolved
Hide resolved
…rage.py to test_usb_read_write.py
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
checkbox-support/checkbox_support/scripts/tests/test_usb_read_write.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
- Simplify test: mock subprocess and check log - Enforce comments under 80 characters - Merge import statements from the same module - Remove unused imports - Update copyright and add author info
|
Thank you for your suggestion. I've committed the changes to the PR again. Please don't hesitate to let me know if anything needs to change. |
|
As mentioned here, please try to remove the changes to the GitHub actions, these shouldn't be needed after the latest fixes, If they still don't work, try rebasing your branch with main again. |
|
Thanks for the feedback. I've removed the GitHub Actions changes and deleted the redundant test file. Please let me know if you have any further suggestions. |
fernando79513
left a comment
There was a problem hiding this comment.
Thanks a lot for finding this bug and for this change!
LGTM +1!
…Fix) (#1717) * Fix NTFS SD card mount failure by adding sync and udevadm settle Fix an issue where Checkbox aborts during the SDHC storage test due to a race condition when mounting an NTFS-formatted SD card. The test fails with: ntfs-3g-mount: mount failed: Device or resource busy because `mount_usb_storage()` executes before Ubuntu's auto-mount process completes. Add `sync` to flush pending writes and `udevadm settle` to wait for udev events, ensuring the device is ready before mounting. Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> * Fix PPA GPG key retrieval issue in CI * Fix CI: Use gpg --dearmor for PPA key handling * Add test for mount_usb_storage functionality * Format test_mount_usb_storage.py using Black * Update test contents from existing file and rename test_mount_usb_storage.py to test_usb_read_write.py * Update test contents and merge tests into test_usb_read_write.py * Apply Black formatting to test_usb_read_write.py * Delet the wrong comment * Apply Black formatting to test_usb_read_write.py * Simplify test: mock subprocess and check log Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Try to keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Merge import statements from the same module Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Remove unused imports Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Update copyright and author Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Refactor and cleanup code - Simplify test: mock subprocess and check log - Enforce comments under 80 characters - Merge import statements from the same module - Remove unused imports - Update copyright and add author info * Remove old test_usb_read_write.py * Revert changes to GitHub Actions configuration in deb_validator.yaml --------- Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
…Fix) (#1717) * Fix NTFS SD card mount failure by adding sync and udevadm settle Fix an issue where Checkbox aborts during the SDHC storage test due to a race condition when mounting an NTFS-formatted SD card. The test fails with: ntfs-3g-mount: mount failed: Device or resource busy because `mount_usb_storage()` executes before Ubuntu's auto-mount process completes. Add `sync` to flush pending writes and `udevadm settle` to wait for udev events, ensuring the device is ready before mounting. Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> * Fix PPA GPG key retrieval issue in CI * Fix CI: Use gpg --dearmor for PPA key handling * Add test for mount_usb_storage functionality * Format test_mount_usb_storage.py using Black * Update test contents from existing file and rename test_mount_usb_storage.py to test_usb_read_write.py * Update test contents and merge tests into test_usb_read_write.py * Apply Black formatting to test_usb_read_write.py * Delet the wrong comment * Apply Black formatting to test_usb_read_write.py * Simplify test: mock subprocess and check log Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Try to keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Merge import statements from the same module Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Remove unused imports Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Update copyright and author Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Refactor and cleanup code - Simplify test: mock subprocess and check log - Enforce comments under 80 characters - Merge import statements from the same module - Remove unused imports - Update copyright and add author info * Remove old test_usb_read_write.py * Revert changes to GitHub Actions configuration in deb_validator.yaml --------- Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
…Fix) (#1717) * Fix NTFS SD card mount failure by adding sync and udevadm settle Fix an issue where Checkbox aborts during the SDHC storage test due to a race condition when mounting an NTFS-formatted SD card. The test fails with: ntfs-3g-mount: mount failed: Device or resource busy because `mount_usb_storage()` executes before Ubuntu's auto-mount process completes. Add `sync` to flush pending writes and `udevadm settle` to wait for udev events, ensuring the device is ready before mounting. Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> * Fix PPA GPG key retrieval issue in CI * Fix CI: Use gpg --dearmor for PPA key handling * Add test for mount_usb_storage functionality * Format test_mount_usb_storage.py using Black * Update test contents from existing file and rename test_mount_usb_storage.py to test_usb_read_write.py * Update test contents and merge tests into test_usb_read_write.py * Apply Black formatting to test_usb_read_write.py * Delet the wrong comment * Apply Black formatting to test_usb_read_write.py * Simplify test: mock subprocess and check log Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Try to keep comments under 80 lines Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Merge import statements from the same module Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Remove unused imports Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Update copyright and author Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com> * Refactor and cleanup code - Simplify test: mock subprocess and check log - Enforce comments under 80 characters - Merge import statements from the same module - Remove unused imports - Update copyright and add author info * Remove old test_usb_read_write.py * Revert changes to GitHub Actions configuration in deb_validator.yaml --------- Signed-off-by: Jeffery Yen <songpao226@gmail.com> Co-authored-by: Wayne Lin <q123456462@gmail.com> Co-authored-by: Fernando Bravo <39527354+fernando79513@users.noreply.github.com>
Fix an issue where Checkbox aborts during the SDHC storage test due to a race condition when mounting an NTFS-formatted SD card. The test fails with:
because
mount_usb_storage()executes before Ubuntu's auto-mount process completes.Add
syncto flush pending writes andudevadm settleto wait for udev events, ensuring the device is ready before mounting.Description
This PR enhances the storage mounting function in Checkbox by adding sync and udevadm settle. These additions ensure that the system has fully registered the device before attempting to mount it, preventing premature failures.
Resolved issues
When running the insertion + read/write + removal test, if the SD card is formatted as NTFS, Checkbox may attempt to mount the device before Ubuntu's auto-mount process is complete. This results in an error log:
which causes the test to abort prematurely.
By adding
syncandudevadm settle, we ensure that the system completes the device registration before proceeding with the mounting process, preventing this issue.Documentation
Tests
The fix was verified by running the following test procedure:
Test Steps:
Run the command:
checkbox-cli run com.canonical.certification::mediacard/sdhc-storage-manualWhen prompted, insert an NTFS-formatted SD card.
Observe the output logs:
syncandudevadm settleensure that the mounting process does not fail due to a premature device state.