Skip to content

Commit 4b552a9

Browse files
committed
fix(applycheck): accept veth ends as links the apply creates
Talos v1.14 added VethConfig, whose two ends (name and peer.name) are links the config brings into existence. The walker had no handler for the kind, so a document referencing either end — a Layer2VIPConfig on a veth, a VLAN parented to one — was validated against the node's existing links and blocked the apply with "declared link not found" on a config Talos accepts. Record both ends the way DummyLinkConfig and LinkAliasConfig are recorded. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent ae0bc30 commit 4b552a9

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

‎docs/manual-test-plan.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ The Section C entries above smoke the apply pipe end-to-end. This section is the
926926
| Typoed VLAN parent | Add `VLANConfig{name: ens5.99, parent: ghost0, vlanID: 99}` (YAML key is `parent`, NOT `link` — `vlan.go ParentLinkConfig`) | Blocker on `parent: ghost0`; `name: ens5.99` not flagged (new VLAN) |
927927
| Typoed bridge slave | Add `BridgeConfig{name: br99, links: [ghost0]}` (YAML key is `links`, NOT `ports` — `bridge.go BridgeLinks`) | Blocker on `ghost0` only; `br99` not flagged |
928928
| Typoed Layer2VIP link | Set `vipLink: ghost0` in values | Blocker on `link: ghost0` |
929+
| VIP on a veth end | Add `VethConfig{name: veth0, peer: {name: veth1}}` plus `Layer2VIPConfig{link: veth1}` | No finding — both ends are links the apply creates (Talos v1.14 kind) |
929930
| Legacy v1.11 interface | `machine.network.interfaces[].interface: eth9999` | Blocker; same hint shape |
930931

931932
#### Disk references

‎pkg/applycheck/refs.go‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ var multidocHandlers = map[string]multidocHandler{
207207
// resolves. WireguardConfig also creates a link but is deliberately
208208
// absent here: it belongs to the parallel net-addr walker, and the
209209
// two dispatch maps must stay disjoint or a kind gets double-walked.
210-
"DummyLinkConfig": handleCreatorOnly,
211-
"LinkAliasConfig": handleCreatorOnly,
210+
"DummyLinkConfig": handleCreatorOnly,
211+
"LinkAliasConfig": handleCreatorOnly,
212+
// A veth pair brings both of its ends into existence (veth.go MetaName
213+
// plus VethPeerConfig.name), so both are recorded rather than validated.
214+
"VethConfig": handleVeth,
212215
"UserVolumeConfig": handleUserVolume,
213216
}
214217

@@ -246,6 +249,19 @@ func handleCreatorOnly(refs []Ref, doc map[string]any, basePath string) []Ref {
246249
return appendCreatedRef(refs, doc, basePath)
247250
}
248251

252+
// handleVeth records both ends of a veth pair as links this config creates:
253+
// the doc's own .name and its .peer.name.
254+
func handleVeth(refs []Ref, doc map[string]any, basePath string) []Ref {
255+
refs = appendCreatedRef(refs, doc, basePath)
256+
257+
peer, ok := doc["peer"].(map[string]any)
258+
if !ok {
259+
return refs
260+
}
261+
262+
return appendCreatedRef(refs, peer, basePath+".peer")
263+
}
264+
249265
// handleListOnly records the doc's own .name as a link this config
250266
// creates, then emits one existing-link ref per entry of its list-valued
251267
// slaves/ports. Used for BondConfig and BridgeConfig: the .name

‎pkg/applycheck/refs_test.go‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,41 @@ kind: LinkConfig
495495
})
496496
}
497497
}
498+
499+
// TestWalkRefs_v1_14_VethCreatesBothEnds pins that a VethConfig seeds both
500+
// ends of the pair into the created-link set, so a document elsewhere in the
501+
// same apply may reference either one. Talos v1.14 added the kind; before it
502+
// was registered the walker ignored it, and a VIP or VLAN pointing at a veth
503+
// end failed validation as a missing link on a config Talos accepts.
504+
func TestWalkRefs_v1_14_VethCreatesBothEnds(t *testing.T) {
505+
t.Parallel()
506+
507+
body := `apiVersion: v1alpha1
508+
kind: VethConfig
509+
name: veth0
510+
peer:
511+
name: veth1
512+
---
513+
apiVersion: v1alpha1
514+
kind: Layer2VIPConfig
515+
link: veth1
516+
ip: 192.0.2.10
517+
`
518+
refs, err := applycheck.WalkRefs([]byte(body))
519+
if err != nil {
520+
t.Fatalf("WalkRefs: %v", err)
521+
}
522+
523+
for _, end := range []string{"veth0", "veth1"} {
524+
if _, ok := findRef(refs, applycheck.RefKindLinkCreated, end); !ok {
525+
t.Errorf("veth end %q not recorded as a created link, got refs=%+v", end, refs)
526+
}
527+
}
528+
529+
findings := applycheck.ValidateRefs(refs, applycheck.HostSnapshot{Links: []string{"ens5"}})
530+
for i := range findings {
531+
if findings[i].IsBlocker() {
532+
t.Errorf("veth-backed VIP blocked the apply: %+v", findings[i])
533+
}
534+
}
535+
}

0 commit comments

Comments
 (0)