fix: resolve --lease-file under --state-dir - #18
Closed
CMGS wants to merge 3 commits into
Closed
Conversation
The daemon hardcoded /var/lib/cocoon/net/leases.json while teardown deletes <state-dir>/leases.json, so a custom --state-dir made the daemon persist leases outside the state directory and teardown remove a file nothing wrote. The flag now defaults to empty and resolves to <state-dir>/leases.json at run time; the default installation path is unchanged. Two adjacent output fixes: --primary-nic help claimed auto-detection when the real fallback is platform.DefaultNIC, and adopt --dry-run did not list the ENI IDs it records into pool.json for teardown to delete.
Contributor
Author
|
Superseded by the rebased branch (same commits on the current main). |
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
--lease-fileno longer hardcodes/var/lib/cocoon/net/leases.json. It defaults to empty and resolves to<state-dir>/leases.jsonat run time, so a custom--state-dirkeeps the daemon's lease file and the pathteardowndeletes in sync.leaseFileNamemoves to the sharedcmdconst block, giving daemon and teardown one owner for the name. The default installation path is unchanged.--primary-nichelp said "auto-detect if empty"; the real fallback isplatform.DefaultNIC(eth0on Volcengine,ens4otherwise). Help and docs now say so.adopt --dry-runprints anenis:row with the ENI IDs it records intopool.jsonand thatteardowndeletes (fix: persist adopted Volcengine ENI IDs #17),nonewhen there are none.Why
With
--state-dir /srv/cocoon/net, the daemon persisted leases to/var/lib/cocoon/net/leases.jsonwhileteardownremoved/srv/cocoon/net/leases.json. Stale leases survived a teardown, and the dry-run gave no preview of the ENI IDs that teardown will delete.Test
TestResolveLeaseFilepins the three cases: default state dir, custom state dir, and an explicit--lease-fileoverriding both. It fails against the pre-fix behaviour:Gates,
GOWORK=off, bothGOOS=linuxandGOOS=darwin:make lint(0 issues each),make fmt-check,asl ./...(0 findings each),go test -race -count=1 ./...all green.