Skip to content

Do not crash at start on NetBSD and OpenBSD#68773

Open
khorben wants to merge 2 commits intosaltstack:masterfrom
khorben:khorben/netbsd-crashes
Open

Do not crash at start on NetBSD and OpenBSD#68773
khorben wants to merge 2 commits intosaltstack:masterfrom
khorben:khorben/netbsd-crashes

Conversation

@khorben
Copy link
Contributor

@khorben khorben commented Feb 26, 2026

What does this PR do?

This PR fixes two crashes when starting salt_master on NetBSD; one of the crashes is expected to affect OpenBSD as well.

What issues does this PR fix or reference?

The patch for salt/grains/core.py avoids accessing an undefined element
of the grains dictionary, on both NetBSD and OpenBSD. This matches the
corresponding code for FreeBSD.

The patch for salt/utils/network.py restricts the OS version test to the
part before "_" on NetBSD; this could raise an exception if py-packaging
wasn't aware of the suffix (e.g., "BETA" would work but "STABLE" not).

Previous Behavior

  File "/usr/pkg/lib/python3.12/site-packages/salt/loader/lazy.py", line 1302, in _run_as
    ret = _func_or_method(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/pkg/lib/python3.12/site-packages/salt/grains/core.py", line 2809, in os_data
    _osrelease_data(grains["os"], grains["osfullname"], grains["osrelease"])
                                  ~~~~~~^^^^^^^^^^^^^^
KeyError: 'osfullname'

And:

  File "/usr/pkg/lib/python3.12/site-packages/salt/utils/network.py", line 1102, in netbsd_interfaces
    if Version(os.uname()[2]) < Version("8.0"):
       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/pkg/lib/python3.12/site-packages/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
packaging.version.InvalidVersion: Invalid version: '10.1_STABLE'

New Behavior

Salt master starts as expected.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

This avoids accessing an undefined element of the grains dictionary, on
both NetBSD and OpenBSD. This matches the corresponding code for
FreeBSD.

Tested on NetBSD/amd64.
This patch restricts the OS version test to the part before "_" on
NetBSD; this could raise an exception if py-packaging wasn't aware of
the suffix (e.g., "BETA" would work but "STABLE" not).

Tested on NetBSD/amd64.
Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a changelog and a test please

@twangboy
Copy link
Contributor

Consider opening this against 3006.x as the bug probably exists there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants