Fix timezone.zone_compare when /etc/localtime is missing on Debian (3006.x)#69809
Open
dwoz wants to merge 1 commit into
Open
Fix timezone.zone_compare when /etc/localtime is missing on Debian (3006.x)#69809dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
Backport of the 3007.x/3008.x/master fix (originally saltstack#65719) to 3006.x. On systemd-managed hosts such as Debian 12 arm64, /etc/localtime may be absent while ``timedatectl`` still reports a valid timezone. Prior to this change, ``timezone.zone_compare`` on 3006.x only bypassed the ``filecmp`` check for Arch and FreeBSD. On Debian it raised ``CommandExecutionError`` from ``filecmp.cmp`` and made the ``timezone.system`` state fail with:: Unable to compare desired timezone 'Europe/Zurich' to system timezone: Failed to read /etc/localtime to determine current timezone: No such file or directory Restructure ``zone_compare`` to trust ``get_zone`` first (which uses ``timedatectl`` when available) and only fall back to the ``filecmp``-based comparison if ``get_zone`` cannot determine the zone. Also simplify ``get_zone``'s os_family branching and use the same ``cmd.run_all`` invocation as newer branches so the unit-test surface matches. Fixes saltstack#69803
twangboy
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Backports the fix for
timezone.zone_comparewhen/etc/localtimeis missing (originally shipped in 3007.x / 3008.x / master via commit8cc89835b41for #65719) to the 3006.x LTS branch.What is the current bug behavior?
On systemd-managed hosts such as Debian 12 arm64,
/etc/localtimemay be absent whiletimedatectlstill reports a valid timezone. On 3006.x,timezone.zone_compareonly bypasses thefilecmp-based check for theArchandFreeBSDfamilies. Every other systemd distro (Debian, RedHat/Alma/Rocky, ...) falls through tofilecmp.cmp(/etc/localtime, ...)which raises:The state module surfaces this as:
What is the new behavior?
zone_comparenow triesget_zone()first (which usestimedatectlwhen available) and only falls back to thefilecmp-based comparison ifget_zonecannot determine the running zone.get_zone's os_family branching is simplified to match newer branches, and_timedatectlis invoked with the samecmd.run_allcall signature as 3007.x+ so the unit-test surface matches.Reproduction
On a Debian 12 minion:
Before this PR: state fails with the error above.
After this PR: state succeeds because the timedatectl-reported zone is trusted.
Tests
test_zone_compare_missing_localtime_with_timedatectlcovers the Debian + missing localtime + timedatectl-reported zone path. Verified it fails against pre-fix 3006.x code and passes with the fix.tests/pytests/unit/modules/test_timezone.py(33 tests) passes.Related
Merge requirements