requested to merge BenWestgate/tails:Fix_Cloner_AttributeError_'NoneType' into stable
During testing I was able to prevent this error from happening 1/4 of clones by adding a 1 second sleep to the top of
format_device, @intrigeri showed me another location this error occurred I could not reproduce but had the same root cause: trying to get properties on a NoneType object because
_get_object was called too soon and allowed to return None.
I found the function
try_getting_udisks_object in the codebase and saw that it retries every 0.1 seconds up to 1 second when
udisksclient.get_object() returns None and so I put that in the return statement of
_get_object so all
_get_object calls will have this additional robustness if the device is not immediately ready when
_get_object is called. This should fix both errors since the underlying cause is the same.
Update: The above changed one error into another type because it would still return objects that weren't usable, I added a
hasattr check for the needed property before returning, that should help. I knew from experience aborted clones fail on retry (if aborted during partitioning). I checked this updated property checking
try_getting_udisks_object and it only sometimes fixed it. So I created a retry decorator function and decorated the problematic functions (all of them involving udisks, since we don't really know the root cause) and this allows it to retry and succeed after the error! So both the "No such interface" and "NoneType" errors should now be cured.
Closes #18986 (closed).