Skip to content

Do not crash at start on NetBSD and OpenBSD - #68773

Merged
dwoz merged 4 commits into
saltstack:masterfrom
khorben:khorben/netbsd-crashes
Oct 30, 2026
Merged

dwoz merged 4 commits into
saltstack:masterfrom
khorben:khorben/netbsd-crashes

Conversation

@khorben

@khorben khorben commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

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

@twangboy twangboy left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

Comment thread salt/grains/core.py Resolved
Comment thread salt/grains/core.py Resolved
twangboy
twangboy previously approved these changes Jul 15, 2026
@twangboy

Copy link
Copy Markdown
Contributor

Please rebase this PR on 3006.x branch and address failing tests if any.

khorben and others added 4 commits October 30, 2026 01:29
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.
Add changelog entry 68773 and unit tests covering:
- netbsd_interfaces() tolerating OS version strings with underscore
  suffixes (e.g. 10.1_STABLE) without raising InvalidVersion
- os_data() correctly setting osfullname on NetBSD and OpenBSD
The new test_netbsd_interfaces_version_with_suffix patches os.uname,
which does not exist on Windows and causes the Windows unit zeromq
job to fail. Add skip_on_windows mark to match the sibling grains
test.

This branch was previously deployed

1 inactive deployment
ci — b14de5c7 Deployed Oct 30, 2026 by khorben via Build Onedir Packages / DEB (arm64) #28170
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.

4 participants