balena-io-modules / balena-preload

Script for preloading containers onto balena device images
https://www.balena.io/
Apache License 2.0
35 stars 8 forks source link

`losetup` fails with `failed to set up loop device: Resource temporarily unavailable` #224

Open majorz opened 4 years ago

majorz commented 4 years ago

Original report:

Running Ubuntu: 20.04 LTS Linux: (5.4.0-40-generic) Docker: 19.03.8, build afacb8b7f0 Node: v12.18.2

Errors are as follows:

Traceback (most recent call last):
File "/usr/src/app/preload.py", line 816, in
PARTITIONS_CACHE[None] = prepare_global_partitions()
File "/usr/src/app/preload.py", line 80, in prepare_global_partitions
return get_partitions(IMAGE)
File "/usr/src/app/preload.py", line 69, in get_partitions
return {p.label: p for p in PartitionTable(image).partitions if p.label}
File "/usr/src/app/preload.py", line 393, in init
part = Partition(self, number, *partition_data)
File "/usr/src/app/preload.py", line 178, in init
self.label = self.get_label()
File "/usr/src/app/preload.py", line 181, in get_label
with self.losetup_context_manager() as device:
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter
return next(self.gen)
File "/usr/src/app/preload.py", line 99, in losetup_context_manager
backoff=2
File "/usr/lib/python3.6/site-packages/retry/api.py", line 101, in retry_call
return __retry_internal(partial(f, *args, *kwargs), exceptions, tries, delay, max_delay, backoff, jitter, logger)
File "/usr/lib/python3.6/site-packages/retry/api.py", line 33, in retry_internal
return f()
File "/usr/lib/python3.6/site-packages/sh.py", line 1427, in __call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/lib/python3.6/site-packages/sh.py", line 774, in init
self.wait()
File "/usr/lib/python3.6/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/usr/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /sbin/losetup -f --show --offset 4194304 --sizelimit 41943040 /img/balena.img

STDOUT:

STDERR:
losetup: /img/balena.img: failed to set up loop device: Resource temporarily unavailable

I looked for other similar cases on GH and found this: https://github.com/flatcar-linux/scripts/commit/ffeca193c0f2936e064b503e85449669ee6b89e2

jellyfish-bot commented 4 years ago

[majorz] This issue has attached support thread https://jel.ly.fish/ea254364-beae-49d8-bbaf-fb6378741d12