Node body: `$patch: delete` + redeclare of the same document loses the redeclared fields
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 65/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 493
- Forks
- 23
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cozystack/talm
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
TestCommittedTextFilesIgnoresUntrackedArtefacts commits into the real repo when GIT_DIR is setAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 70/100
-
area/apply area/commands area/upgrade kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de cozystack/talm
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Correct local module testing instructions for Go sample contributorsPosiblemente ocupada @slievrly la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
internal/core: cleanAttachmentName splits a rune at the 255-byte cap and stores invalid UTF-8Posiblemente ocupada @pacwestnobody la tomó hoy. Abiertogo good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Podiom/Podiom#427 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
TestLaunchGolden spends about 98 seconds on fake-agent exit delays under -racePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
factory:subtask
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
Los mantenedores suelen responder en 1 día