Skip to content

[bitnami/external-dns] Fix bug with trailing comma in azure.json #33951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025

Conversation

MaxAnderson95
Copy link
Contributor

@MaxAnderson95 MaxAnderson95 commented May 28, 2025

This PR resolves #33882.

A breaking change was introduced in external-dns 0.17.0 which now (correctly) fails to parse a previously innocuous bug in how the azure.json was generated in this chart. Since the introduction of workload identity support in this chart (and likely before), the Azure credentials were generated by constructing a raw JSON string. When using only workload identity, this resulted in an invalid azure.json containing a trailing comma on the last key-value pair:

{
  "tenantId": "11111111-1111-1111-1111-111111111111",
  "subscriptionId": "0000000-0000-0000-0000-000000000000",
  "resourceGroup": "foo-group",
  "useWorkloadIdentityExtension":  true,
}

In external-dns 0.16.1 this was apparently accepted as valid JSON and did not cause a parsing error. Since the upgrade to chart version 8.8.3 which included external-dns 0.17.0, this is now causing a parsing error:

failed to read Azure config file '/etc/kubernetes/azure.json': failed to parse Azure config file '/etc/kubernetes/azure.json': invalid character '}' looking for beginning of object key string

Description of the change

This PR uses the toJson helm function to dynamically generate the JSON object, eliminating the need to worry about key order or trailing commas.

Benefits

The method is much cleaner rather than constructing a raw string.

Possible drawbacks

One slight drawback is that falsey values now appear in the JSON object passed to azure.json.

Before:

{
  "tenantId": "11111111-1111-1111-1111-111111111111",
  "subscriptionId": "0000000-0000-0000-0000-000000000000",
  "resourceGroup": "foo-group",
  "useWorkloadIdentityExtension":  true,
}

After:

{
  "aadClientId": "",
  "aadClientSecret": "",
  "cloud": "",
  "resourceGroup": "foo-group",
  "subscriptionId": "0000000-0000-0000-0000-000000000000",
  "tenantId": "11111111-1111-1111-1111-111111111111",
  "useManagedIdentityExtension": false,
  "useWorkloadIdentityExtension": true,
  "userAssignedIdentityID": ""
}

I tested in one of my test clusters and had no issues, and I also reviewed the relevant parsing code and found no indication it would handle falsey values differently than non-existent keys.

Applicable issues

Checklist

  • Chart version bumped in Chart.yaml according to semver. This is not necessary when the changes only affect README.md files.
  • Title of the pull request follows this pattern [bitnami/<name_of_the_chart>] Descriptive title
  • All commits signed off and in agreement of Developer Certificate of Origin (DCO)

@github-actions github-actions bot added external-dns triage Triage is needed labels May 28, 2025
@github-actions github-actions bot requested a review from carrodher May 28, 2025 22:35
@MaxAnderson95 MaxAnderson95 changed the title Fix bug with trailing comma in azure.json [bitnami/external-dns] Fix bug with trailing comma in azure.json May 28, 2025
@MaxAnderson95 MaxAnderson95 marked this pull request as ready for review May 28, 2025 22:36
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels May 29, 2025
@github-actions github-actions bot removed the triage Triage is needed label May 29, 2025
@github-actions github-actions bot removed the request for review from carrodher May 29, 2025 09:03
@github-actions github-actions bot requested a review from migruiz4 May 29, 2025 09:03
Copy link
Member

@migruiz4 migruiz4 left a comment

Choose a reason for hiding this comment

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

Hi there!

Thank you for your contribution @MaxAnderson95! I agree that using toJson here is the way to go, but I'm worried about transforming the entire .Values.azure into azure.json.

In the future, extra values may be added under .Values.azure that we may not want to add into the azure.json and cause issues for existing deployments by accident.

I would rather keep logic similar to how it currently is:

  • Build a dict from scratch.
  • Add key-values individually.
  • Then convert the dict using toJson (instead of printing it line by line as it currently is).

It is not as pretty, but it would give us better control over what is included in the final Json.
If external-dns adds a new supported field for the azure.json, then we just need to add a new value to the values.yaml and update the helper.

@MaxAnderson95
Copy link
Contributor Author

MaxAnderson95 commented May 29, 2025

Hi there!

Thank you for your contribution @MaxAnderson95! I agree that using toJson here is the way to go, but I'm worried about transforming the entire .Values.azure into azure.json.

In the future, extra values may be added under .Values.azure that we may not want to add into the azure.json and cause issues for existing deployments by accident.

I would rather keep logic similar to how it currently is:

  • Build a dict from scratch.
  • Add key-values individually.
  • Then convert the dict using toJson (instead of printing it line by line as it currently is).

It is not as pretty, but it would give us better control over what is included in the final Json. If external-dns adds a new supported field for the azure.json, then we just need to add a new value to the values.yaml and update the helper.

No worries, better safe than sorry! I'll get those changes pushed soon.

EDIT: Changes pushed, ready for re-review

@MaxAnderson95
Copy link
Contributor Author

@migruiz4 can you re-review this?

@MaxAnderson95
Copy link
Contributor Author

Sorry for the notification spam. I screwed up trying to fix a merge conflict. Anyway I think we're good now.

@carrodher carrodher removed the triage Triage is needed label Jun 10, 2025
@carrodher carrodher removed their assignment Jun 10, 2025
@carrodher carrodher removed their request for review June 10, 2025 07:38
Signed-off-by: Bitnami Bot <[email protected]>
@MaxAnderson95
Copy link
Contributor Author

@migruiz4 sorry to bother, but do you mind re-reviewing the changes you requested? I keep having to re-base this PR because changes are being made in other branches.

Copy link
Member

@migruiz4 migruiz4 left a comment

Choose a reason for hiding this comment

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

I'm very sorry for the late response @MaxAnderson95, thank you for applying my suggestion!

@migruiz4 migruiz4 merged commit 7ce5a57 into bitnami:main Jun 26, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-dns solved verify Execute verification workflow for these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azure.json cannot be parsed when working with workload identity
5 participants