openSUSE / salt-formulas

Custom Salt formulas used in the openSUSE and SUSE infrastructures
GNU General Public License v3.0
6 stars 2 forks source link

libvirt.guests "unbuffered text I/O" #200

Open tacerus opened 1 week ago

tacerus commented 1 week ago
          ID: libvirt_guests_sysconfig_file
    Function: file.managed
        Name: /etc/sysconfig/libvirt-guests
      Result: True
     Comment: Empty file
     Started: 10:19:00.222726
    Duration: 4.376 ms
     Changes:
              ----------
              new:
                  file /etc/sysconfig/libvirt-guests created
----------
          ID: libvirt_guests_sysconfig
    Function: suse_sysconfig.sysconfig
        Name: libvirt-guests
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.6/site-packages/salt/state.py", line 2402, in call
                  *cdata["args"], **cdata["kwargs"]
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1282, in wrapper
                  return f(*args, **kwargs)
                File "/var/cache/salt/minion/extmods/states/suse_sysconfig.py", line 86, in sysconfig
                  header_pillar=header_pillar,
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1282, in wrapper
                  return f(*args, **kwargs)
                File "/var/cache/salt/minion/extmods/states/suse_sysconfig.py", line 36, in header
                  repl=patterns['replace'],
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1282, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/states/file.py", line 5403, in replace
                  backslash_literal=backslash_literal,
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1234, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/modules/file.py", line 2616, in replace
                  with salt.utils.files.fopen(path, mode="w", buffering=bufsize) as w_file:
                File "/usr/lib/python3.6/site-packages/salt/utils/files.py", line 393, in fopen
                  f_handle = open(*args, **kwargs)  # pylint: disable=resource-leakage
              ValueError: can't have unbuffered text I/O

The file is empty at this time.

tacerus commented 1 week ago

Adding a character to the file makes the state run.

On a short glance, I think the underlying file.replace state in suse_sysconfig.header does not support empty files. This should ideally be worked around in the suse_sysconfig states. Alternatively the file.managed state in libvirt.guests could be amended to already add the header?