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

AttributeError: 'Loop' object has no attribute 'fd' #9

Closed
ondrejbudai opened this issue Nov 23, 2023 · 1 comment · Fixed by #13
Closed

AttributeError: 'Loop' object has no attribute 'fd' #9

ondrejbudai opened this issue Nov 23, 2023 · 1 comment · Fixed by #13

Comments

@ondrejbudai
Copy link
Member

After #6 is fixed/worked around, people are running into this issue. I saw it myself, but not every time. I think that it depends on whether the host system ran osbuild before you run it in a container after a reboot. I guess that some extra initial setup of loop devices might be needed in the container.

This might be the same issue as Michael Hofmann hit when trying to run osbuild in a container: https://gitlab.com/cki-project/experimental/osbuild-example/-/blob/main/osbuild-composer-loopback.service?ref_type=heads

Note that this might be host-distro specific.

⏱  Duration: 0s
org.osbuild.copy:
5d96bf6806bf5ba0999439a1fd7cbb4b44328b943a8e3b8b6196849bede191e8 {
   "paths": [
     {
       "from": "input://root-tree/",
       "to": "mount://-/"
     }
   ]
}
device/- (org.osbuild.loopback): loop0 acquired (locked: False)
device/boot (org.osbuild.loopback): Exception ignored in: <function
Loop.__del__ at 0x7f2b38fd63e0>
device/boot (org.osbuild.loopback): Traceback (most recent call last):
device/boot (org.osbuild.loopback):   File
"/usr/lib/python3.12/site-packages/osbuild/loop.py", line 137, in __del__
device/boot (org.osbuild.loopback):     self.close()
device/boot (org.osbuild.loopback):   File
"/usr/lib/python3.12/site-packages/osbuild/loop.py", line 144, in close
device/boot (org.osbuild.loopback):     fd, self.fd = self.fd, -1
device/boot (org.osbuild.loopback):                   ^^^^^^^
device/boot (org.osbuild.loopback): AttributeError: 'Loop' object has no
attribute 'fd'
Traceback (most recent call last):
   File "/usr/bin/osbuild", line 33, in <module>
     sys.exit(load_entry_point('osbuild==99', 'console_scripts',
'osbuild')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/main_cli.py", line
169, in osbuild_cli
     r = manifest.build(
         ^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/pipeline.py", line
468, in build
     res = pl.run(store, monitor, libdir, stage_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/pipeline.py", line
372, in run
     results = self.build_stages(store,
               ^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/pipeline.py", line
345, in build_stages
     r = stage.run(tree,
         ^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/pipeline.py", line
218, in run
     devices[name] = devmgr.open(dev)
                     ^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/devices.py", line 92,
in open
     res = client.call("open", args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 348,
in call
     ret, _ = self.call_with_fds(method, args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 384,
in call_with_fds
     raise error
osbuild.host.RemoteError: FileNotFoundError: [Errno 2] No such file or
directory: 'loop1'
    File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 268,
in serve
     reply, reply_fds = self._handle_message(msg, fds)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 301,
in _handle_message
     ret, fds = self.dispatch(name, args, fds)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/devices.py", line
127, in dispatch
     r = self.open(args["dev"],
         ^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/osbuild/devices/org.osbuild.loopback", line 104, in open
     raise error from None
   File "/usr/lib/osbuild/devices/org.osbuild.loopback", line 101, in open
     self.lo = self.make_loop(self.fd, start, size, lock)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/osbuild/devices/org.osbuild.loopback", line 81, in
make_loop
     lo = self.ctl.loop_for_fd(fd, lock=lock,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/loop.py", line 649,
in loop_for_fd
     lo = Loop(self.get_unbound())
          ^^^^^^^^^^^^^^^^^^^^^^^^
   File "/usr/lib/python3.12/site-packages/osbuild/loop.py", line 128,
in __init__
     self.fd = os.open(self.devname, os.O_RDWR, dir_fd=dir_fd)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@mvo5
Copy link
Collaborator

mvo5 commented Nov 23, 2023

One (small) step forward with this should be osbuild/osbuild#1467 to ensure we get correct error reporting from open(). The underlying issue is in the stracktrace:

   File "/usr/lib/python3.12/site-packages/osbuild/host.py", line 384,
in call_with_fds
     raise error
osbuild.host.RemoteError: FileNotFoundError: [Errno 2] No such file or
directory: 'loop1'

but that is hidden from the top because of the incorrect cleanup in del.

Sorry if I'm stating the obvious here but I wanted to spell it out as it was not obvious at first to me.

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 a pull request may close this issue.

2 participants