Repository navigation
Make salt user home and extras dir configurable (#69402) - #69403
Conversation
|
Added package-level integration tests at
Each test spins up its own function-scoped The original unit-level |
|
Diagnosed the CI red and pushed 785d458. Three real bugs surfaced by the new package tests: Bug 1 (DEB): Fresh install with Fix: every DEB preinst's Bug 2 (RPM): The RPM Fix: source Bug 3 (Windows collection): module-level Test hardening:
The 27 unit-level tests in New SHA: 785d458 |
Redact HTTP credentials in get_source_sum errors and prefix early get_managed failures with "Unable to manage file" so test_issue_60203 passes. Skip distro-wide upgrades during --no-install pkg sessions so yum/apt cannot replace the onedir under test, and always run the package upgrade in test_salt_upgrade even when the pre-upgrade pip check fails.
Import escape from rich.markup and wrap pprint output so PR merge refs against current 3006.x no longer crash Prepare Workflow Run.
Resolve tools/ci.py quote-style conflicts while keeping the escape import and pprint logging wrappers needed for workflow-config.
yum update -y and apt upgrade -y can replace the onedir under test with a newer Salt release from the Salt repos (e.g. 3008.0), causing test_salt_upgrade to fail because the installed version exceeds the artifact version. Exclude salt* from yum and hold/unhold salt packages on Debian so the system upgrade only touches non-Salt packages. Verified in a Rocky Linux 8 container: yum update -y upgrades salt-minion 3006.25 to 3008.0; yum update -y --exclude=salt* leaves salt-minion at 3006.25.
install_previous() downloads salt.repo from salt-install-guide which
enables both salt-repo-3006-lts and salt-repo-3008-lts by default. When
yum install runs without version pinning, it picks 3008.0 from the
3008-lts repo (newer than 3006.25), causing test_salt_upgrade to fail
with: assert Version('3008.0') <= Version('3006.25+107.ga508051fad').
The existing code only disabled salt-repo-3007-sts but left 3008-lts
enabled. Add symmetric handling to disable salt-repo-3008-lts unless
the target prev_version is 3008.x.
Reproduced in ghcr.io/saltstack/salt-ci-containers/testing:rockylinux-9:
- Without fix: yum install salt* installs 3008.0 from salt-repo-3008-lts
- With fix: yum install salt* installs 3006.25 from salt-repo-3006-lts
Commit 09cd140 changed managed() to prefix error messages from file.get_managed with 'Unable to manage file:' to fix test_issue_60203. This broke two tests that expected the raw message without the prefix: - test_patch_saltenv: patch() calls managed() internally and returns its result directly. The comment now includes the prefix. - test_managed: the mock for file.get_managed returns True as the comment value; managed() now wraps it as 'Unable to manage file: True'.
…nges After a password change on Windows, the post-change comparison detects that user.info's password_changed timestamp and shadow.info's lstchg field both changed. These are side effects of the password change and are already captured by passwd: XXX-REDACTED-XXX. Reporting them separately makes ret.changes wider than intended and breaks the test_win_user_present_new_password assertion. Pop password_changed and lstchg from ret.changes when on Windows and _passwd_changed is True so the only reported change is passwd.
…hive tarball path The commit 8bfd5c4 on 3006.x added a `git add -f salt/_version.txt` step before pip install in salt_onedir(), but passed cwd=str(salt_archive) where salt_archive is the path to the .tar.gz file, not a directory. This caused `NotADirectoryError` at runtime. Fix by passing cwd=str(tools.utils.REPO_ROOT) so git runs in the repository root where the tracked file actually lives.
What does this PR do?
Makes the salt system user's home directory and the relenv
extras-<py-ver>directory configurable across both Linux packaging stacks. Every DEB preinst (andsalt-minion.postinst) now sources/etc/default/salt-setupand/etc/sysconfig/salt-minion-setupbefore applying theSALT_HOME/SALT_USER/SALT_GROUP/SALT_NAMEdefaults, mirroring the existing RPM%pre/%post minionbehavior. A newSALT_EXTRAS_DIRoverride is honored by both stacks so the extras tree can be relocated outside/opt/saltstack/salt.What issues does this PR fix or reference?
Fixes #69402
Previous Behavior
SALT_HOME/SALT_USER/SALT_GROUP/SALT_NAMEexported in the environment beforeapt install. There was no equivalent of RPM's/etc/sysconfig/salt-minion-setupconfig-file override.pkg/rpm/salt.spec(%post minionupgrade branch) was hardcoded to discover anyextras-*directory under/opt/saltstack/saltviafind(1)and offered no relocation knob. The DEBsalt-minion.postinsthad no extras handling at all.New Behavior
/etc/default/salt-setup(DEB-conventional) or/etc/sysconfig/salt-minion-setup(RPM-conventional, accepted on DEB for cross-distro parity) can be pre-created withSALT_HOME=...,SALT_USER=..., etc. and is picked up at install time on either stack. The historical "export the var before apt install" path still works.SALT_EXTRAS_DIRknob is honored by the RPM%post minionupgrade chown and the DEBsalt-minion.postinst configurestep. When unset, the previous behavior (RPM:find(1)discovery under/opt/saltstack/salt; DEB: chown/opt/saltstack/saltrecursively) is preserved.Test plan
tests/pytests/unit/test_pkg_scripts.pyruns each DEB preinst's override-resolution prelude under bash with a redirected/etc, asserting the defaults, env-var override,/etc/default/salt-setupoverride, and/etc/sysconfig/salt-minion-setupoverride all resolve correctly. Two grep-based regression assertions cover the RPMSALT_EXTRAS_DIRknob and the preservedfind(1)fallback.Merge requirements satisfied?
Commits signed with GPG?
No