Skip to content

[Fix]: Upgrade across 3006.15 (0r 3007.7) generates spurious ppbt toolchain#68782

Merged
dwoz merged 2 commits intosaltstack:3006.xfrom
cjriches:3006.x
Mar 12, 2026
Merged

[Fix]: Upgrade across 3006.15 (0r 3007.7) generates spurious ppbt toolchain#68782
dwoz merged 2 commits intosaltstack:3006.xfrom
cjriches:3006.x

Conversation

@cjriches
Copy link

@cjriches cjriches commented Mar 4, 2026

What does this PR do?

Move compileall to %posttrans to avoid accidental ppbt toolchain extract

The RPM specfile runs compileall in %post to byte-compile Python modules
under /opt/saltstack/salt/lib. This worked fine until commit 48c7d58
(Bump relenv version to 0.20.0).

In relenv >=0.20.0, the interpreter bootstrap actively imports ppbt and
extracts toolchains if available, rather than just checking if they're
already there. This should not have been a problem, as commit 4bd2832
(Remove ppbt after building the salt onedir) removed ppbt from the final
package so it never gets installed at runtime.

However, the subtleties of RPM scriptlet ordering cause issues on
upgrade. The %post scriptlet executes after the new version has been
installed, but before the stale files of the old version have been
removed. This means that ppbt is still present when the compileall runs,
so the bootstrap hooks extract the ppbt toolchain into
/root/.local/relenv.

This is usually harmless, but silently eats about 215 MiB of disk space,
which can be anywhere from mildly annoying to severely damaging
depending on how tight the root filesystem is.

Since both 48c7d58 and 4bd2832 went into 3006.15, any in-place
upgrade of salt that crosses this version will generate this spurious
toolchain.

Move the compileall into %posttrans, at which point we guarantee the old
package has been completely removed and we are only acting on the
correct python libraries.
Remove stale pycache on upgrade

When we regenerate the pycache on upgrade, stale files from removed
libraries may persist. Clear everything out first to avoid this.

For consistency, change the existing pycache clear-on-uninstall to use
the simpler -delete pattern instead of invoking xargs.

What issues does this PR fix or reference?

Fixes #68781

Merge requirements satisfied?

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

Commits signed with GPG?

No

@cjriches cjriches requested a review from a team as a code owner March 4, 2026 14:59
@dwoz dwoz added the test:full Run the full test suite label Mar 4, 2026
dwoz
dwoz previously approved these changes Mar 4, 2026
@cjriches
Copy link
Author

cjriches commented Mar 5, 2026

Ah, looks like the tests don't expect the posttrans. Will update.

(I see there are also some upgrade tests, but I reckon this is too weird and niche of an issue to be worth a specialised regression test?)

cjriches added 2 commits March 5, 2026 11:51
The RPM specfile runs compileall in %post to byte-compile Python modules
under /opt/saltstack/salt/lib. This worked fine until commit 48c7d58
(Bump relenv version to 0.20.0).

In relenv >=0.20.0, the interpreter bootstrap actively imports ppbt and
extracts toolchains if available, rather than just checking if they're
already there. This should not have been a problem, as commit 4bd2832
(Remove ppbt after building the salt onedir) removed ppbt from the final
package so it never gets installed at runtime.

However, the subtleties of RPM scriptlet ordering cause issues on
upgrade. The %post scriptlet executes after the new version has been
installed, but before the stale files of the old version have been
removed. This means that ppbt is still present when the compileall runs,
so the bootstrap hooks extract the ppbt toolchain into
/root/.local/relenv.

This is usually harmless, but silently eats about 215 MiB of disk space,
which can be anywhere from mildly annoying to severely damaging
depending on how tight the root filesystem is.

Since both 48c7d58 and 4bd2832 went into 3006.15, any in-place
upgrade of salt that crosses this version will generate this spurious
toolchain.

Move the compileall into %posttrans, at which point we guarantee the old
package has been completely removed and we are only acting on the
correct python libraries.
When we regenerate the pycache on upgrade, stale files from removed
libraries may persist. Clear everything out first to avoid this.

For consistency, change the existing pycache clear-on-uninstall to use
the simpler -delete pattern instead of invoking xargs.
@dwoz dwoz merged commit ad9e286 into saltstack:3006.x Mar 12, 2026
827 of 829 checks passed
@welcome
Copy link

welcome bot commented Mar 12, 2026

Congratulations on your first PR being merged! 🎉

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.

3 participants