Skip to content

fix(parameters): backfill absent externalManaged config hash#10166

Merged
leon-ape merged 1 commit intomainfrom
bugfix/externalmanaged-config-hash-backfill
Apr 23, 2026
Merged

fix(parameters): backfill absent externalManaged config hash#10166
leon-ape merged 1 commit intomainfrom
bugfix/externalmanaged-config-hash-backfill

Conversation

@weicao
Copy link
Copy Markdown
Contributor

@weicao weicao commented Apr 22, 2026

Fixes #10167

Summary

This follow-up patch backfills an absent ConfigHash for externalManaged configs in ParameterTemplateExtension.

Today ParameterTemplateExtension already resolves the rendered ConfigMap and backfills component.spec.configs[].configMap, but it does not carry the rendered ConfigMap hash back into component.spec.configs[].configHash. That leaves the desired spec incomplete on the initial external-managed path even though the rendered ConfigMap already has a real hash.

This patch keeps the fix narrow:

  • backfill ConfigHash only when it is absent (nil or empty)
  • read the hash from the rendered ConfigMap label config.kubeblocks.io/config-hash
  • do not overwrite an existing non-empty ConfigHash
  • do not add a transformer-layer fallback in this PR

Flow

ComponentParameter
  renders the externalManaged config
  creates the rendered ConfigMap
  rendered ConfigMap already has hash: config.kubeblocks.io/config-hash
        |
        |  This PR backfills the missing metadata here:
        |  when writing the ConfigMap reference back to Component.spec.configs,
        |  also write the hash back to Component.spec.configs[].configHash.
        v
Component.spec.configs
  Before: name + configMap, but configHash is absent
  After:  name + configMap + configHash
        |
        v
InstanceSet.spec.configs / Pod annotation
  Later controllers use this desired state to compare config consistency.

In short, this PR records the already-computed rendered ConfigMap fingerprint into the desired spec. It complements #10163: #10163 improves downstream controller robustness for absent-hash representations, while this PR improves upstream desired-state completeness for the initial externalManaged path.

Why Here

ParameterTemplateExtension is already the place where the rendered ConfigMap is read and the ConfigMap reference is written back into Component.spec.configs. Adding the initial hash backfill here keeps the desired spec complete at the source instead of pushing this responsibility down to workload transform.

Changes

  • controllers/parameters/parametertemplateextension_controller.go
    • backfill absent ConfigHash from the rendered ConfigMap label during external-managed config update
  • controllers/parameters/parametertemplateextension_controller_test.go
    • add helper-level coverage for:
      • absent hash is backfilled from rendered ConfigMap labels
      • existing non-empty hash is not overwritten
      • missing label keeps the hash absent
    • add controller-level coverage that external-managed config reconciliation now writes the rendered hash into Component.spec.configs[].configHash

Validation

KUBEBUILDER_ASSETS="$(./bin/setup-envtest-release-0.21 use 1.26.1 -p path)" \
go test ./controllers/parameters -count=1 -- -ginkgo.focus='ParameterExtension Controller'

Out of Scope

  • transformer fallback for externalManaged && configHash == nil
  • continuous mirroring of live rendered hash back into desired spec after initial backfill
  • #10163 controller absent-hash compatibility fix

@weicao weicao requested review from a team and kizuna-lek as code owners April 22, 2026 13:33
@apecloud-bot
Copy link
Copy Markdown
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.1

@github-actions github-actions Bot added the size/M Denotes a PR that changes 30-99 lines. label Apr 22, 2026
@weicao
Copy link
Copy Markdown
Contributor Author

weicao commented Apr 22, 2026

/nopick

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.41%. Comparing base (769e4ce) to head (47aa261).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10166      +/-   ##
==========================================
+ Coverage   52.15%   52.41%   +0.25%     
==========================================
  Files         529      529              
  Lines       60078    60097      +19     
==========================================
+ Hits        31335    31497     +162     
+ Misses      25623    25477     -146     
- Partials     3120     3123       +3     
Flag Coverage Δ
unittests 52.41% <100.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@apecloud-bot apecloud-bot added the approved PR Approved Test label Apr 23, 2026
@leon-ape leon-ape merged commit 7f36b8e into main Apr 23, 2026
77 of 82 checks passed
@leon-ape leon-ape deleted the bugfix/externalmanaged-config-hash-backfill branch April 23, 2026 02:20
@github-actions github-actions Bot added this to the Release 1.2.0 milestone Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR Approved Test nopick Not auto cherry-pick when PR merged size/M Denotes a PR that changes 30-99 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: externalManaged rendered config hash is not backfilled into desired spec

4 participants