fix(sysctl): decide from the drop-in, not from the record - #567
Merged
Merged
Conversation
Create returned Changed: false whenever a KV state entry existed with no UndeployedAt, without reading the host and without comparing the value it was asked for. deploy already compares against the file on disk, so the pre-check was the only thing standing between a request and the right answer. Three cases it got wrong. A drop-in edited by hand stood, because the record still said managed. A deleted drop-in was never restored, for the same reason. And create with a different value on a managed key reported no change and left the old value in place, which needed nobody to touch the host at all. The test that covered this asserted the defect: the record held 0, the request asked for 1, and it expected Changed: false. It is replaced by four cases covering unchanged content, a changed value, a hand edit and a deletion. Against the previous implementation they fail ten times. Every other provider already decides this way. ntp and cron say so in their own comments. Closes #564 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #567 +/- ##
==========================================
- Coverage 99.95% 99.95% -0.01%
==========================================
Files 501 501
Lines 24084 24073 -11
==========================================
- Hits 24074 24063 -11
Misses 10 10
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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.
Closes #564.
CreatereturnedChanged: falsewhenever a KV state entry existed with noUndeployedAt, without reading the host and without comparing the value it was asked for.deployalready compares against the file on disk and has a comment saying so. The pre-check was the only thing standing between a request and the right answer, so the fix is deleting it.Three cases it got wrong
The third needed nobody to touch the host.
Create(key, "1")thenCreate(key, "0")returnedChanged: falseboth times and left1.The test asserted the defect
The record holds
0, the request asks for1, and it expects no change. That is the bug written down as the specification.Replaced with four cases: unchanged content, a changed value, a hand edit, and a deletion. Each asserts the file contents afterwards rather than only the
Changedflag.Proof they catch it
Consistency
Every other provider already decides this way:
file,ntpandnetplanhash the file on disk,userreadsauthorized_keys, andcron,certificateandservicedelegate tofileDeployer. sysctl was the only one left.ntpandcronboth say so in their own comments. sysctl's said "returns Changed: false if the key is already managed", which was the bug stated as intent. It now reads like theirs.Contract: osapi-io/specs#238.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FuKUsHFG1EqZXamffh9M2c