saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.17k stars 5.48k forks source link

[BUG] ValueError: No closing quotation #63092

Closed j5k closed 1 year ago

j5k commented 1 year ago

Description salt-call ends in ValueError: No closing quotation

Setup

Steps to Reproduce the behavior

# salt-call state.highstate
/usr/lib/python3.10/site-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
ValueError: No closing quotation
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 33, in <module>
    sys.exit(load_entry_point('salt==3005.1', 'console_scripts', 'salt-call')())
  File "/usr/lib/python3.10/site-packages/salt/scripts.py", line 441, in salt_call
    client.run()
  File "/usr/lib/python3.10/site-packages/salt/cli/call.py", line 40, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 42, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 303, in __init__
    super().__init__(opts)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 63, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/lib/python3.10/site-packages/salt/minion.py", line 920, in __init__
    opts["grains"] = salt.loader.grains(opts)
  File "/usr/lib/python3.10/site-packages/salt/loader/__init__.py", line 1116, in grains
    ret = funcs[key]()
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/grains/core.py", line 3094, in kernelparams
    item.split("=") for item in salt.utils.args.shlex_split(cmdline)
  File "/usr/lib/python3.10/site-packages/salt/utils/args.py", line 278, in shlex_split
    shlex.split(salt.utils.stringutils.to_str(s), **kwargs)
  File "/usr/lib/python3.10/shlex.py", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 33, in <module>
    sys.exit(load_entry_point('salt==3005.1', 'console_scripts', 'salt-call')())
  File "/usr/lib/python3.10/site-packages/salt/scripts.py", line 441, in salt_call
    client.run()
  File "/usr/lib/python3.10/site-packages/salt/cli/call.py", line 40, in run
    caller = salt.cli.caller.Caller.factory(self.config)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 42, in factory
    return ZeroMQCaller(opts, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 303, in __init__
    super().__init__(opts)
  File "/usr/lib/python3.10/site-packages/salt/cli/caller.py", line 63, in __init__
    self.minion = salt.minion.SMinion(opts)
  File "/usr/lib/python3.10/site-packages/salt/minion.py", line 920, in __init__
    opts["grains"] = salt.loader.grains(opts)
  File "/usr/lib/python3.10/site-packages/salt/loader/__init__.py", line 1116, in grains
    ret = funcs[key]()
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/salt/grains/core.py", line 3094, in kernelparams
    item.split("=") for item in salt.utils.args.shlex_split(cmdline)
  File "/usr/lib/python3.10/site-packages/salt/utils/args.py", line 278, in shlex_split
    shlex.split(salt.utils.stringutils.to_str(s), **kwargs)
  File "/usr/lib/python3.10/shlex.py", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation

Expected behavior Run without error

Versions Report

salt --versions-report ```yaml Salt Version: Salt: 3005.1 Dependency Versions: cffi: 1.15.1 cherrypy: Not Installed dateutil: Not Installed docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 3.1.2 libgit2: Not Installed M2Crypto: 0.38.0 Mako: Not Installed msgpack: 1.0.4 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: 2.21 pycrypto: Not Installed pycryptodome: 3.12.0 pygit2: Not Installed Python: 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] python-gnupg: Not Installed PyYAML: 6.0 PyZMQ: 24.0.1 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.4 ```
welcome[bot] commented 1 year ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

OrangeDog commented 1 year ago

You've cut off the end of the versions report.

What is the output of cat /proc/cmdline?

j5k commented 1 year ago
# cat /etc/kernel/cmdline 
rd.luks.name==luks rd.luks.options=rw,bgrt_disable root=/dev/mapper/luks rootflags=subvol=@root_2022-11-21_10-03-47 lockdown=confidentiality
System Versions:
          dist: arch Timestamp: 2022-11-21 10:03 | Kernel: 6.0.9 
        locale: utf-8
       machine: x86_64
       release: 6.0.9-arch1-1
        system: Linux
       version: Arch Linux Timestamp: 2022-11-21 10:03 | Kernel: 6.0.9
OrangeDog commented 1 year ago

/proc/cmdline, not /etc/kernel/cmdline

j5k commented 1 year ago

It's the same.

OrangeDog commented 1 year ago

That's odd then, because shlex_split appears to parse it just fine.

j5k commented 1 year ago

What does that mean? Are the kernel parameters involved in some way here?

OrangeDog commented 1 year ago

Yes, the stack trace indicates a failure to parse the kernel parameters, as if they contained a random quote character.

j5k commented 1 year ago

Okay I have to apologize! I looked again and saw characters, which I overlooked yesterday. There are random characters at the end and one of them is a quote. I regenerate my initial ramdisk (mkinitcpio), but nothing changed. Where do these random characters come from?

j5k commented 1 year ago

I suspect that it is not a salt problem and close this issue. If you have some more suggestions, I am very open to it. Thanks!

I have asked directly in the arch forum: https://bbs.archlinux.org/viewtopic.php?id=281500

j5k commented 1 year ago

Workaround exists and fix on the way in systemd (https://github.com/systemd/systemd/pull/25222)