Skip to content

fix: mixed patch formats - #497

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:bug-496
Aug 8, 2026
Merged

fix: mixed patch formats#497
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:bug-496

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

sveltos-agent-config and sveltos-applier-config support both legacy bare patches and structured libsveltosv1beta1.Patch documents, but the two formats couldn't be mixed in one ConfigMap. The same override mechanism is used for per-cluster overrides via the
sveltosagent.projectsveltos.io/config-override-ref and sveltosapplier.projectsveltos.io/config-override-ref annotations.

getPatchesFromConfigMap parsed the whole ConfigMap as structured Patch documents. A single legacy-formatted entry caused that parse to fail for the entire ConfigMap. getSveltosAgentPatches then fell back to getSveltosAgentPatchesOld, which treated every entry, including already structured ones, as a raw legacy patch.

This PR fixes that by making the legacy/structured fallback happen per ConfigMap entry instead of per ConfigMap.

Fixes #496

`sveltos-agent-config` and `sveltos-applier-config` support both legacy bare
patches and structured `libsveltosv1beta1.Patch` documents, but the two
formats couldn't be mixed in one ConfigMap. The same override mechanism is
used for per-cluster overrides via the
`sveltosagent.projectsveltos.io/config-override-ref` and
`sveltosapplier.projectsveltos.io/config-override-ref` annotations.

`getPatchesFromConfigMap` parsed the whole ConfigMap as structured `Patch`
documents. A single legacy-formatted entry caused that parse to fail for the
entire ConfigMap. `getSveltosAgentPatches` then fell back to
`getSveltosAgentPatchesOld`, which treated every entry, including already
structured ones, as a raw legacy patch.

This PR fixes that by making the legacy/structured fallback happen per
ConfigMap entry instead of per ConfigMap.
@gianlucam76

Copy link
Copy Markdown
Member Author

Tested locally with

apiVersion: v1
kind: ConfigMap
metadata:
  name: sveltos-agent-config
  namespace: projectsveltos
data:
  # Legacy bare-patch format: raw StrategicMerge patch, no "patch:" wrapper.
  # Adds label fv-legacy-patch=applied to the sveltos-agent-manager Deployment.
  legacy-patch: |-
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: sveltos-agent-manager
      labels:
        fv-legacy-patch: applied

  # Structured libsveltosv1beta1.Patch format: JSON6902 under "patch:", with
  # optional explicit "target:". Adds label fv-structured-patch=applied.
  structured-patch: |-
    patch: |-
      - op: add
        path: /metadata/labels/fv-structured-patch
        value: applied
    target:
      kind: Deployment
      group: apps
      name: sveltos-agent-manager

The sveltos-agent deployment

  apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      deployment.kubernetes.io/revision: "1"
    creationTimestamp: "2026-08-08T15:45:48Z"
    generation: 1
    labels:
      control-plane: sveltos-agent
      fv-legacy-patch: applied
      fv-structured-patch: applied
    name: sveltos-agent-manager
    namespace: projectsveltos

@gianlucam76
gianlucam76 merged commit 62a11c0 into projectsveltos:main Aug 8, 2026
9 checks passed
@gianlucam76
gianlucam76 deleted the bug-496 branch August 8, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: mixed patch formats trigger ConfigMap-wide legacy fallback

1 participant