Skip to content

chrony: add UCI options for drift file and time restoration - #30799

Open
drizt wants to merge 1 commit into
openwrt:masterfrom
drizt:chrony_driftfile
Open

drizt wants to merge 1 commit into
openwrt:masterfrom
drizt:chrony_driftfile

Conversation

@drizt

@drizt drizt commented Oct 17, 2026 •

Copy link
Copy Markdown

chronyd can restore the system time at startup from the drift file's modification time. This helps routers without a real-time clock recover a more recent time after reboot when the drift file is stored on persistent storage.

Add a UCI section to configure the drift file path, its minimum update interval, and optional time restoration using chronyd's -s option. Keep time restoration disabled by default and preserve the existing drift file path for configurations without the new section.

config driftfile 'driftfile'
    # Set to 1 to restore time from the drift file at startup
    option restore_time '0'
    # Use a path on persistent storage to retain the file across reboots
    option file '/var/run/chrony/drift'
    # Minimum update interval in seconds; empty uses chronyd's default
    option interval ''

📦 Package Details

Maintainer: @mlichvar
(You can find this by checking the history of the package Makefile.)

Description:
See commit message


🧪 Run Testing Details

  • OpenWrt Version: 25.12.5 r33051-f5dae5ece4
  • OpenWrt Target/Subtarget: ramips/mt7621
  • OpenWrt Device: ASUS RT-AX53U

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

@openwrt

openwrt Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Formality Check: Failed

We checked this pull request against the contribution guidelines. Here is what needs your attention:

🛑 CRITICAL ERRORS

Commit 38aac5d - chrony: add UCI options for drift file and time restoration:

  • File 'net/chrony/files/chrony.conf' is destined for '/etc/config/' but is not a valid UCI configuration file. In OpenWrt, '/etc/config/' is reserved for UCI-formatted configuration files. Raw files (such as TOML, JSON, or YAML) are not allowed at this path. Invalid line 2: 'confdir /var/etc/chrony.d'

Tip

Do not close this pull request to make corrections. Instead, modify your existing commits (e.g. git commit --amend) and update the branch using git push --force-with-lease --force-if-includes. The checks will re-run automatically.


Something broken? Consider reporting an issue.
Running version 37cc78e deployed on 2026-10-15 12:36:36 CEST

@drizt

drizt commented Oct 17, 2026

Copy link
Copy Markdown
Author

File 'net/chrony/files/chrony.conf' is destined for '/etc/config/' but is not a valid UCI configuration file. In OpenWrt, '/etc/config/' is reserved for UCI-formatted configuration files. Raw files (such as TOML, JSON, or YAML) are not allowed at this path. Invalid line 2: 'confdir /var/etc/chrony.d'

It's not mine file. The file from original package. I only removed two lines in it.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 1 new commit; inline notes only.


Generated by Claude Code

Comment thread net/chrony/files/chronyd.init Outdated

procd_open_instance
procd_set_param command $PROG -n
[ "$restore_time" == "1" ] && procd_append_param command -s

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: == is a bashism; the rest of this script uses POSIX = in [ ] tests.

Suggested change
[ "$restore_time" == "1" ] && procd_append_param command -s
[ "$restore_time" = "1" ] && procd_append_param command -s

Generated by Claude Code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed.

rtcsync

# Record the clock's drift
driftfile /var/run/chrony/drift

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/etc/chrony/chrony.conf is a conffile, so if a user has modified it, the upgrade keeps their copy with this driftfile line. That line comes after confdir (line 2), so it overrides the UCI-generated directive and the new file/interval options are silently ignored. Is that acceptable, or should the upgrade path handle it (e.g. a note in the commit message, or a uci-defaults/sed migration)?


Generated by Claude Code

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's acceptable. User which modifies /etc/chrony/chrony.conf knows what he does. My patch just changes place of driftfile /var/run/chrony/drift but doesn't change behavior.

chronyd can restore the system time at startup from the drift file's
modification time. This helps routers without a real-time clock recover
a more recent time after reboot when the drift file is stored on
persistent storage.

Add a UCI section to configure the drift file path, its minimum update
interval, and optional time restoration using chronyd's -s option.
Keep time restoration disabled by default and preserve the existing
drift file path. New section created by uci-defaults.

```uci
config driftfile 'driftfile'
    # Set to 1 to restore time from the drift file at startup
    option restore_time '0'
    # Use a path on persistent storage to retain the file across reboots
    option file '/var/run/chrony/drift'
    # Minimum update interval in seconds; empty uses chronyd's default
    option interval ''
```

Signed-off-by: Ivan Romanov <drizt72@zoho.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants