Repository navigation
fix(spored): reload reaches the running daemon (#1278) - #1289
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
spored reload used to reload a throwaway agent in its own process. It now signals the daemon (SIGHUP to the unit's main pid; SCM ParamChange on Windows); the monitor loop refreshes and publishes /run/spored/reloaded.json, which reload waits for and prints. Non-zero when the daemon is not running, does not acknowledge, or failed to refresh. config set notifies the same way. Agent.Reload now reads and swaps config under configMu. Fixes #1278
scttfrdmn
force-pushed
the
fix/1278-reload-reaches-daemon
branch
from
October 24, 2026 04:44
1bd8ed7 to
3d98b20
Compare
Merged
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.
Fixes #1278
spored reloadused to reload a throwaway agent (NewAgentForQuery) in its own process and print that agent's config. The daemon kept its old config until its periodic refresh. Now:runDaemonsubscribes to SIGHUP first thing, so a request during startup is queued and does not stop the process. Requests go throughAgent.RequestReload, a non-blocking, coalescing channel, into theMonitorselect loop. The loop runsReloadon its own goroutine and publishesagent.ReloadMarker(pid, seq, error, config summary incl. TTL deadline and cost limit) to/run/spored/reloaded.json, next to the existing/run/spored/*files. Monitor publishes a seq-0 marker at start.svc.AcceptParamChange, andserviceControlActionmaps ParamChange to the same request.spored reloadsends ParamChange through the SCM. The marker goes to%PROGRAMDATA%\spored\reloaded.json.spored reload:systemctl show --property=MainPID spored, or the SCM's ProcessId).spored config set: notifies the daemon the same way and no longer runs a throwaway reload. The ttl read-back now comes from the daemon's marker.Agent.Reload: reads and swaps the config throughcfg()/setConfig.spawn extend: the command string is unchanged. Its success line now says the daemon reloaded.Deviation from the plan: the plan said
systemctl kill -s HUP spored. This signals the unit's main pid instead. By defaultsystemctl killsignals every process in the cgroup, which includes plugin steps spored runs (pkg/pluginruntime), and SIGHUP would kill them. The pid is also needed for the marker check. The unit file is not touched.Gates (each watched failing against a revert that compiles):
TestMonitor_ReloadRequestRefreshesRunningAgent: a running Monitor with a 1h ticker. The test changes the stub's config, requests a reload, then asserts the running agent adopted it, exactly 1 RefreshConfig,configRefreshTick == 0, and a marker with seq 1. Revert (drop the select case): the test fails waiting for the request.TestReload_SwapsUnderConfigMu: concurrent GetConfig under -race, plus Reload blocking while configMu is held. Revert toa.config = newConfig(write only, or read+write): DATA RACE / "completed while configMu was held".TestReload_NoDaemonFails,TestReload_NoAcknowledgementFails(bound counted in polls),TestReload_IgnoresMarkersThatAreNotTheAcknowledgement,TestReload_DoesNotSignalADaemonWithoutAMarker: reverting the pid==0 check, or returning success on no ack, fails them.TestNotifyReload_SIGHUP: subscribing a different signal kills the test binary with SIGHUP.TestServiceControl_ParamChangeReloads/TestRequestReload_ReachesNotifyReload: compiled locally with GOOS=windows only; they run on the Windows CI job.