fix(charts,commands): skip empty bond config and honor --endpoints in init#201
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request prevents the emission of BondConfig documents for bond interfaces that have no enslaved links. This change addresses an issue where Talos 1.13 auto-creates bond stubs, which, if rendered as empty BondConfig documents, are rejected by Talos. The PR includes a template update in _helpers.tpl to skip empty bonds and adds a regression test with a corresponding mock topology. I have no feedback to provide as there were no review comments.
3971ac3 to
4b25602
Compare
… init
Two operator-visible bugs in the talm init / multidoc-render flow.
* charts: cozystack + generic presets emit BondConfig with empty
`links:` for any discovered link with `spec.kind == "bond"`. The
Talos link controller can auto-create a bond stub in COSI link
state before any operator configuration enslaves physical NICs
to it — the master link carries a `bondMaster` spec but no other
link has `slaveKind: bond` + `masterIndex` pointing at it.
Rendering the document under those conditions ships
`BondConfig{name: bond0, links: <empty>, bondMode: ...}` to
Talos, which rejects on apply with `BondConfig/bond0: at least
one link must be specified`. Skip the document when
`talm.discovered.bond_slaves` returns an empty list: a
discovered bond without enslaved links is a stub, not a
user-configured bond. An operator who intends a bond declares
its slaves via a per-node body overlay. Pattern mirrors the
existing fail-fast guardrail for VLAN-without-parent in the
same files; chose skip over fail-fast because the operator
does not control the Talos-side stub creation.
* commands: `talm init --endpoints X` silently wrote `127.0.0.1`
to the generated talosconfig. The assignment site at
init.go:598 hardcoded `defaultLocalEndpoint`, discarding the
operator's flag. Extract `resolveTalosconfigEndpoints`:
when `GlobalArgs.Endpoints` is non-empty, propagate; otherwise
fall back to the loopback placeholder (yaml requires a
non-empty endpoints list; operator edits after init in that
case). Helper returns a defensive copy so callers mutating the
talosconfig field do not alias the operator-visible
`GlobalArgs.Endpoints` across init invocations.
Tests:
- TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig
pins the cozystack-side bond-skip contract: rendered output
must contain neither `kind: BondConfig` nor `name: bond0`
when slaves is empty. Positive-shape assertions verify that
eth0 (non-enslaved, has an address) still emits as a
LinkConfig so a future guard regression swallowing all link
emission does not slip through.
- TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig_Generic
pins the generic-preset counterpart against the same shape.
- TestResolveTalosconfigEndpoints_{GlobalNonEmpty_UsesGlobal,
GlobalEmpty_UsesLoopbackFallback, ReturnsCopy,
MultipleEndpoints} pin the helper's four behaviour axes:
operator-supplied propagation, fallback shape, defensive
copy, multi-endpoint shape.
emptyBondTopologyLookup fixture mirrors bondTopologyLookup but
drops eth0/eth1 enslavement so talm.discovered.bond_slaves
returns an empty list — exactly the Talos auto-stub shape.
Existing TestContract_NetworkMultidoc_BondRendersBondConfig and
TestContract_NetworkMultidoc_BondSlavesNotEmittedAsLinkConfig
keep passing: slaves-present case unaffected.
Scope: covers both multidoc (v1.12+) presets cozystack + generic.
The legacy v1.11 nested form in charts/talm/templates/_helpers.tpl
::talm.discovered.bond_config exhibits the same empty-slaves
shape; deliberately out of scope because the multidoc presets are
where the reported reproduction lives and the legacy path has
different downstream test coverage. Follow up if 1.11 operators
hit this shape.
Signed-off-by: Aleksei Sviridkin <f@lex.la>
4b25602 to
44c6520
Compare
What
Two operator-visible bugs in the talm init / multidoc-render flow.
Empty-slaves bond emits invalid BondConfig
Both the
cozystackandgenericpresets unconditionally renderedBondConfig{name: bond0, links: <empty>, bondMode: ...}for any discovered link withspec.kind == "bond". Talos's link controller can auto-create a bond stub in COSI link state before any operator configuration enslaves physical NICs to it — the master link carries abondMasterspec but no other link hasslaveKind: bond+masterIndexpointing at it. Under those conditions the rendered document fails Talos validation withBondConfig/bond0: at least one link must be specified.Fix: skip the BondConfig document when
talm.discovered.bond_slavesreturns an empty list. A discovered bond without enslaved links is a stub, not a user-configured bond. An operator who intends a bond declares its slaves via a per-node body overlay.Pattern mirrors the existing fail-fast guardrail for VLAN-without-parent in the same files; chose skip over fail-fast because the operator does not control the Talos-side stub creation, so forcing them to declare the bond explicitly would be a usability regression.
talm init --endpoints Xsilently writes127.0.0.1to talosconfigThe assignment site at
pkg/commands/init.go:598hardcodeddefaultLocalEndpoint, discarding the operator's--endpointsflag. Fix: extractresolveTalosconfigEndpoints: whenGlobalArgs.Endpointsis non-empty, propagate; otherwise fall back to the loopback placeholder. Helper returns a defensive copy so callers mutating the talosconfig field do not alias the operator-visibleGlobalArgs.Endpointsacross init invocations.Tests
TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig(NEW) — pins the cozystack-side bond-skip contract. Assertskind: BondConfigandname: bond0absent when slaves is empty, AND that the non-enslaved physical link still emits as a LinkConfig (positive-shape pin against a guard that accidentally swallows all link emission).TestContract_NetworkMultidoc_BondWithoutSlaves_SkipsBondConfig_Generic(NEW) — counterpart for the generic preset.TestResolveTalosconfigEndpoints_{GlobalNonEmpty_UsesGlobal, GlobalEmpty_UsesLoopbackFallback, ReturnsCopy, MultipleEndpoints}(NEW) — pin the helper's four behaviour axes.emptyBondTopologyLookupfixture mirrorsbondTopologyLookupbut drops eth0/eth1 enslavement sotalm.discovered.bond_slavesreturns an empty list.TestContract_NetworkMultidoc_BondRendersBondConfigand_BondSlavesNotEmittedAsLinkConfigkeep passing — slaves-present case unaffected.Local CI:
go test ./...clean,golangci-lint run ./...0 issues,GOOS=windows go vet ./...clean.Scope
Covers both multidoc (v1.12+) presets —
cozystackandgeneric. The legacy v1.11 nested form lives incharts/talm/templates/_helpers.tpl::talm.discovered.bond_configand exhibits the same empty-slaves shape; deliberately out of scope here because the multidoc presets are where the reported reproductions live and the legacy path has different downstream test coverage. Track as a follow-up if 1.11 operators hit this shape.