Skip to content

fix: mixed patch formats - #1909

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

fix: mixed patch formats#1909
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:bug-1908

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

drift-detection-config supports both legacy bare patches and structured libsveltosv1beta1.Patch documents, but the two formats couldn't be mixed in one ConfigMap.

getPatchesFromConfigMap parsed the whole ConfigMap as structured Patch documents. A single legacy-formatted entry caused that parse to fail for the entire ConfigMap. That caused 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 #1908

`drift-detection-config` supports both legacy bare patches and structured
`libsveltosv1beta1.Patch` documents, but the two formats couldn't be mixed
in one ConfigMap.

`getPatchesFromConfigMap` parsed the whole ConfigMap as structured `Patch`
documents. A single legacy-formatted entry caused that parse to fail for the
**entire** ConfigMap. That caused **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

Locally tried with this ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: drift-detection-config
  namespace: projectsveltos
data:
  # Legacy bare-patch format: raw StrategicMerge patch, no "patch:" wrapper.
  # Adds label fv-legacy-patch=applied to the drift-detection-manager Deployment.
  legacy-patch: |-
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: drift-detection-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: drift-detection-manager

The drift-detection deployment is

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

@gianlucam76
gianlucam76 merged commit 217fb11 into projectsveltos:main Aug 8, 2026
11 checks passed
@gianlucam76
gianlucam76 deleted the bug-1908 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