Skip to content

[16.0] fs_storage: issues with the rooted_dir_file_system #513

@hnavarro-kernet

Description

@hnavarro-kernet

We are experiencing this intermittent issue where any uploads or reads from a configured fs.storage with s3fs are raising FileNotFoundError anytime os.getcwd() is called.

Module

fs_storage

Describe the bug

Mostly, anytime you try to see an image, upload an attachment, etc. if Odoo has to "contact" the external S3 bucket, it will raise FileNotFoundError from os.getcwd().

To Reproduce

Affected versions:
16.0
Possible anything else with the rooted_dir_file_system

Steps to reproduce the behavior:

  1. If you have the bug, just refresh the record. For example in a project.task I sent some images to my customer, if I refresh the task, the images won't load or load sometimes and other times not.

Expected behavior
Issue not raising.

Additional context

Traceback (most recent call last):
  File "/opt/odoo/OCB/odoo/http.py", line 2234, in __call__
    response = request._serve_db()
  File "/opt/odoo/OCB/odoo/http.py", line 1822, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/OCB/odoo/service/model.py", line 152, in retrying
    result = func()
  File "/opt/odoo/OCB/odoo/http.py", line 1850, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/OCB/odoo/http.py", line 1964, in dispatch
    return self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/OCB/addons/website/models/ir_http.py", line 237, in _dispatch
    response = super()._dispatch(endpoint)
  File "/opt/odoo/OCB/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/OCB/odoo/http.py", line 761, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/OCB/addons/web/controllers/binary.py", line 171, in content_image
    return stream.get_response(**send_file_kwargs)
  File "/opt/odoo/kernet/oca/fs_attachment/fs_stream.py", line 72, in get_response
    res = _send_file(f, **send_file_kwargs)
  File "/opt/odoo/OCB/odoo/tools/_vendor/send_file.py", line 104, in send_file
    if isinstance(path_or_file, (os.PathLike, str)) or hasattr(
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 1142, in __getattr__
    self.__enter__()
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 989, in __enter__
    self._file_open()
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 1009, in _file_open
    fs, _storage, fname = self.attachment._get_fs_parts()
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 594, in _get_fs_parts
    return self._fs_parse_store_fname(self.store_fname)
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 527, in _fs_parse_store_fname
    fs = self._get_fs_storage_for_code(storage_code)
  File "/opt/odoo/kernet/oca/fs_attachment/models/ir_attachment.py", line 511, in _get_fs_storage_for_code
    fs = self.env["fs.storage"].get_fs_by_code(code)
  File "<decorator-gen-142>", line 2, in get_fs_by_code
  File "/opt/odoo/OCB/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/kernet/oca/fs_storage/models/fs_storage.py", line 227, in get_fs_by_code
    fs = fs_storage.fs
  File "/opt/odoo/kernet/oca/fs_storage/models/fs_storage.py", line 323, in fs
    raise e
  File "/opt/odoo/kernet/oca/fs_storage/models/fs_storage.py", line 319, in fs
    self._check_connection(self.__fs, self.check_connection_method)
  File "/opt/odoo/kernet/oca/fs_storage/models/fs_storage.py", line 306, in _check_connection
    self._ls_check_connection(fs)
  File "/opt/odoo/kernet/oca/fs_storage/models/fs_storage.py", line 300, in _ls_check_connection
    fs.ls("", detail=False)
  File "/opt/odoo/odooenv/lib/python3.8/site-packages/fsspec/implementations/dirfs.py", line 254, in ls
    ret = self.fs.ls(self._join(path), detail=detail, **kwargs).copy()
  File "/opt/odoo/kernet/oca/fs_storage/rooted_dir_file_system.py", line 47, in _join
    path_posix = os.path.normpath(make_path_posix(path))
  File "/opt/odoo/odooenv/lib/python3.8/site-packages/fsspec/implementations/local.py", line 304, in make_path_posix
    return f"{os.getcwd()}/{path}"
FileNotFoundError: [Errno 2] No such file or directory

A successful read looks like this:

2025-09-16 09:30:15,024 660916 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: ********************************************************************************
2025-09-16 09:30:15,024 660916 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: rooted_dir path: <bucket-name>/<file-checksum>
2025-09-16 09:30:15,024 660916 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: rooted_dir self.path: <bucket-name>
2025-09-16 09:30:15,025 660916 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: rooted_dir os.getcwd(): /opt/odoo
2025-09-16 09:30:15,025 660916 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: ********************************************************************************

A failed read looks like this:

2025-09-16 09:30:14,956 660907 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: ********************************************************************************
2025-09-16 09:30:14,956 660907 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: rooted_dir path: <bucket-name>
2025-09-16 09:30:14,956 660907 INFO odoo odoo.addons.fs_storage.rooted_dir_file_system: rooted_dir self.path: <bucket-name>
2025-09-16 09:30:14,956 660907 ERROR odoo odoo.addons.fs_storage.rooted_dir_file_system: [Errno 2] No such file or directory

In our /etc/systemd/system/odoo.service we have specified the WorkingDirectory:
WorkingDirectory=/opt/odoo

Any clue or fixes for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions