Node body: `$patch: delete` + redeclare of the same document loses the redeclared fields
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Start by locating engine.MergeFileAsPatch, which the issue identifies as the function used by talm template and apply, and trace how it prunes body fields before merging documents. Use the two YAML files in the reproduction to check how a deleted identity that is redeclared is handled. Done means the redeclared BondConfig retains all its fields and matches the documented talosctl machineconfig patch result.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
talm version: v0.36.0 (preset cozystack, Talos v1.14 multi-doc)
What happens
A node body that deletes a rendered document and declares it again in full (a common way to replace a document, since a strategic merge can only append to lists) does not survive MergeFileAsPatch. Before merging, talm prunes every body field that already equals the rendered value. The redeclared document is pruned down to the fields that differ, then the $patch: delete next to it removes the rendered document, so whatever the rendered side provided is gone.
Depending on what differs, the document either disappears entirely or is left without required fields. In our case talm apply -i on a node in maintenance mode failed with:
BondConfig/bond0: bond mode must be specified
talosctl machineconfig patch applies the same body correctly, so the body itself is valid.
Why we need it
On a running control-plane node, discovery reports a Layer2 VIP that is not floatingIP/vips (here, a second public API VIP declared as its own Layer2VIPConfig in the node body) as an address of the bond. The rendered BondConfig then carries the VIP as a static /32, and a merge can only append to addresses. Deleting and redeclaring the bond in the node body is the only way we found to keep the VIP out of the static addresses.
Minimal reproduction
rendered.yaml (what the chart renders with discovery):
version: v1alpha1
machine:
type: worker
token: dummy
ca: {crt: "", key: ""}
cluster:
controlPlane: {endpoint: "https://192.0.2.10:6443"}
---
apiVersion: v1alpha1
kind: BondConfig
name: bond0
links: [eth0, eth1]
bondMode: 802.3ad
miimon: 100
addresses:
- address: 192.0.2.5/24
- address: 198.51.100.7/32 # VIP seen by discovery on a running node
routes:
- gateway: 192.0.2.1
node.yaml (node body):
apiVersion: v1alpha1
kind: BondConfig
name: bond0
$patch: delete
---
apiVersion: v1alpha1
kind: BondConfig
name: bond0
links: [eth0, eth1]
bondMode: 802.3ad
miimon: 100
addresses:
- address: 192.0.2.5/24
routes:
- gateway: 192.0.2.1
Driver (calls the same function talm template/apply use for the node body):
package main
import (
"fmt"
"os"
"github.com/cozystack/talm/pkg/engine"
)
func main() {
r, _ := os.ReadFile(os.Args[1])
out, err := engine.MergeFileAsPatch(r, os.Args[2])
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
os.Stdout.Write(out)
}
Result
Output for bond0 |
|
|---|---|
talosctl machineconfig patch rendered.yaml --patch @node.yaml (expected) |
full BondConfig bond0 with links, bondMode, miimon, one address, the route |
engine.MergeFileAsPatch(rendered.yaml, node.yaml) |
no BondConfig bond0 at all |
same, with miimon: 100 removed from rendered.yaml |
BondConfig bond0 with only miimon: 100, so talosctl validate fails with bond mode must be specified |
Expected
When a body contains a $patch: delete for a document identity and also redeclares that identity, the redeclared document should be applied as written: no pruning against the rendered document that is being deleted. This matches talosctl machineconfig patch.
Workaround
Render with talm template --offline --full, apply the body with talosctl machineconfig patch --patch @nodes/<host>.yaml, and apply the result with talosctl apply-config.
- Lingua principale
- Go
- Stelle
- 493
- Fork
- 23
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cozystack/talm
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
TestCommittedTextFilesIgnoresUntrackedArtefacts commits into the real repo when GIT_DIR is setAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 70/100
-
area/apply area/commands area/upgrade kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tutte le issue di cozystack/talm
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Correct local module testing instructions for Go sample contributorsForse già presa @slievrly l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
internal/core: cleanAttachmentName splits a rune at the 255-byte cap and stores invalid UTF-8Forse già presa @pacwestnobody l’ha presa oggi. Apertago good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Podiom/Podiom#427 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
TestLaunchGolden spends about 98 seconds on fake-agent exit delays under -raceForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
factory:subtask
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 1 giorno