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

[Bug]: slurm.conf editor doesn't correctly handle RebootProgram option #32

Closed
NucciTheBoss opened this issue Nov 13, 2024 · 0 comments · Fixed by #33
Closed

[Bug]: slurm.conf editor doesn't correctly handle RebootProgram option #32

NucciTheBoss opened this issue Nov 13, 2024 · 0 comments · Fixed by #33
Labels
Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug.

Comments

@NucciTheBoss
Copy link
Member

Bug Description

The parse_line helper function fails to correctly parse the RebootProgram option after a new slurm.conf file has been dumped by the editor. The issue is caused be the fact that the marshaller does not encapsulate the value of RebootProgram in quotations when dumping the new configuration to a file. The option RebootProgram="/usr/sbin/reboot --reboot" becomes RebootProgram=/usr/sbin/reboot --reboot

Then, if you attempt to re-edit the slurm.conf file, parse_line will split the option into two tokens: "RebootProgram=/usr/sbin/reboot" and --reboot. parse_line will then raise a ValueError because there's no = character in --reboot.

opts = shlex.split(line) # Use `shlex.split(...)` to preserve quotation strings.
for opt in opts:
k, v = opt.split("=", maxsplit=1)

The easiest fix is to just generalize ReasonCallback to QuoteCallback and then set QuoteCallback as the callback to use when parsing the RebootProgram option.

To Reproduce

from slurmutils.models import SlurmConfig

SlurmConfig.from_str("RebootProgram=/usr/sbin/reboot --reboot")
# See `ValueError` be raised.

Environment

Juju Ubuntu 22.04 LXD image, Python 3.10.12

Relevant log output

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/nucci/git/slurm-charms/venv/lib/python3.12/site-packages/slurmutils/models/slurm.py", line 272, in from_str
    data.update(parse_line(SlurmConfigOptionSet, config))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nucci/git/slurm-charms/venv/lib/python3.12/site-packages/slurmutils/models/model.py", line 98, in parse_line
    k, v = opt.split("=", maxsplit=1)
    ^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Additional context

Issue discovered as work on charmed-hpc/slurm-charms#35

@NucciTheBoss NucciTheBoss added Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug. labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Analysis of issue needs to completed before work can be undertaken. Type: Bug Issue reports a bug, or pull request fixes a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant