Skip to content

fix(helm): use | as sed delimiter for cert substitution#7322

Closed
rajsinghtech wants to merge 1 commit intokarmada-io:masterfrom
rajsinghtech:fix/helm-ca-crt-sed-delimiter
Closed

fix(helm): use | as sed delimiter for cert substitution#7322
rajsinghtech wants to merge 1 commit intokarmada-io:masterfrom
rajsinghtech:fix/helm-ca-crt-sed-delimiter

Conversation

@rajsinghtech
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it

The sed commands in the pre-install and pre-upgrade Jobs that substitute {{ ca_crt }} (and other cert placeholders) with actual base64-encoded certificate values use / as the delimiter. Since base64-encoded values can contain / characters, this breaks the sed substitution pattern, leaving raw {{ ca_crt }} placeholders in the karmada-static-resources ConfigMap.

When the karmada-static-resource Job subsequently runs kubectl apply -f /static-resources/, it fails with:

error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{"ca_crt":interface {}(nil)}

This is because {{ ca_crt }} is interpreted as a YAML flow mapping rather than a string value.

How this PR fixes it

Switches all sed commands in pre-install-job.yaml and pre-upgrade-job.yaml from using / to | as the delimiter. The | character cannot appear in base64-encoded output (A-Za-z0-9+/=), making it a safe delimiter choice.

Which issue(s) this PR fixes

Fixes #7321

Does this PR introduce a user-facing change?

Fixed Helm chart pre-install and pre-upgrade Jobs where certificate placeholder substitution could fail due to sed delimiter conflicts with base64-encoded values.

Copilot AI review requested due to automatic review settings March 23, 2026 06:17
@karmada-bot karmada-bot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 23, 2026
@karmada-bot karmada-bot requested a review from jrkeen March 23, 2026 06:17
@karmada-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign seanlaii for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot requested a review from seanlaii March 23, 2026 06:17
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the Helm chart's pre-installation and pre-upgrade processes. It resolves an issue where sed commands, used for substituting base64-encoded certificate values, failed due to conflicts with the default / delimiter. By switching to | as the delimiter, the chart can now correctly process and apply certificate data, preventing deployment failures and ensuring proper configuration of static resources.

Highlights

  • Sed Delimiter Conflict Resolution: Changed the sed command delimiter from / to | in Helm chart pre-install and pre-upgrade jobs to prevent issues with base64-encoded certificate values containing / characters.
  • Helm Chart Certificate Substitution Fix: Resolved a bug where certificate placeholders (e.g., {{ ca_crt }}) were not correctly substituted in karmada-static-resources ConfigMaps, which previously led to YAML parsing errors during kubectl apply.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot karmada-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Helm hook Jobs that substitute certificate placeholders (e.g., {{ ca_crt }}) with base64-encoded certificate data, which can contain / and break sed substitutions when / is used as the delimiter.

Changes:

  • Updated sed substitutions in the pre-install Job to use | as the delimiter for all cert placeholder replacements.
  • Updated sed substitutions in the pre-upgrade Job to use | as the delimiter when patching existing ConfigMaps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
charts/karmada/templates/pre-install-job.yaml Switches all cert-related sed substitutions to use `
charts/karmada/templates/pre-upgrade-job.yaml Switches ca_crt substitution to use `

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…l and pre-upgrade jobs

The sed commands that replace {{ ca_crt }} and other cert placeholders use /
as the delimiter. Base64-encoded certificate values can contain / characters,
which breaks the sed substitution and leaves raw {{ ca_crt }} placeholders in
the static-resources ConfigMap. This causes the karmada-static-resource Job to
fail with a YAML parsing error when applying the APIService resources.

Switch all sed commands in pre-install-job.yaml and pre-upgrade-job.yaml to use
| as the delimiter instead, since | cannot appear in base64-encoded output.

Fixes karmada-io#7321

Signed-off-by: Raj Singh <rajsinghcpre@gmail.com>
Signed-off-by: Raj Singh <raj@tailscale.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a critical bug in the Helm chart's pre-install and pre-upgrade jobs. The change correctly updates the sed delimiter from / to | when substituting base64-encoded certificate values. This resolves the issue where the original delimiter could conflict with characters in the base64 strings, leading to failed substitutions and incorrect YAML parsing. The chosen delimiter | is a suitable replacement as it is not present in base64 encoding, ensuring the reliability of certificate provisioning.

@rajsinghtech rajsinghtech force-pushed the fix/helm-ca-crt-sed-delimiter branch from da3037c to d6ec1ca Compare March 23, 2026 06:18
@XiShanYongYe-Chang
Copy link
Copy Markdown
Member

Thank you for the quick fix.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.03%. Comparing base (5ba1066) to head (d6ec1ca).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7322   +/-   ##
=======================================
  Coverage   42.02%   42.03%           
=======================================
  Files         874      874           
  Lines       53551    53551           
=======================================
+ Hits        22505    22508    +3     
+ Misses      29354    29351    -3     
  Partials     1692     1692           
Flag Coverage Δ
unittests 42.03% <ø> (+<0.01%) ⬆️

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.

@zhzhuang-zju
Copy link
Copy Markdown
Contributor

Thanks @rajsinghtech.

The sed commands in the pre-install and pre-upgrade Jobs that substitute {{ ca_crt }} (and other cert placeholders) with actual base64-encoded certificate values use / as the delimiter. Since base64-encoded values can contain / characters, this breaks the sed substitution pattern, leaving raw {{ ca_crt }} placeholders in the karmada-static-resources ConfigMap.

I'm fine with replacing / with |. It seems to have no side effects and can eliminate concerns about / breaking the sed substitution pattern.

However, I wonder if / actually breaks the sed substitution pattern. Based on the analysis in the comment #7185 (comment) and years of CI testing, this issue shouldn't occur. Please correct me if my analysis is wrong.

@rajsinghtech
Copy link
Copy Markdown
Contributor Author

Closing — can't confirm the root cause and the maintainers couldn't reproduce. The | delimiter change is defensive but not fixing a verified bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helm chart: v1beta2.custom.metrics.k8s.io APIService has raw {{ ca_crt }} placeholder in static-resources ConfigMap

6 participants