Skip to content

Fix NAD config to produce valid JSON for Multus webhook#12

Closed
newgoliath wants to merge 2 commits into
mainfrom
fix/create-network-valid-json
Closed

Fix NAD config to produce valid JSON for Multus webhook#12
newgoliath wants to merge 2 commits into
mainfrom
fix/create-network-valid-json

Conversation

@newgoliath
Copy link
Copy Markdown

Summary

  • The _config variable in create_network.yaml was defined as a Python-style dict string with single quotes (e.g. {'cniVersion':'0.3.1', ...})
  • When passed through | to_json, Ansible wraps this as a JSON string literal rather than converting it to valid JSON, producing "{'cniVersion':...}" with single quotes
  • Multus admission webhook rejects this with: "configuration string is not in JSON format"
  • Fix: convert _config to a proper YAML dictionary so | to_json serializes it correctly with double quotes

Test plan

  • Deploy a catalog item that creates NetworkAttachmentDefinitions (e.g. lb1404-vmware-migration-cnv)
  • Verify NAD is created successfully without Multus webhook rejection

🤖 Generated with Claude Code

The _config variable was defined as a Python-style dict string with single
quotes, which `| to_json` wraps as a quoted string rather than converting to
valid JSON. Multus rejects this with "configuration string is not in JSON
format". Convert _config to a proper YAML dictionary so `to_json` serializes
it correctly with double quotes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@agonzalezrh agonzalezrh left a comment

Choose a reason for hiding this comment

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

Is this related to a new ansible version?

@newgoliath
Copy link
Copy Markdown
Author

Is this related to a new ansible version?

yes. I'm migrating the VMware workloads from v1, and there seems to be some code path here that are tool old for v2.

@newgoliath newgoliath requested a review from agonzalezrh March 26, 2026 19:36
@newgoliath
Copy link
Copy Markdown
Author

also - it's a little prettier. 😉
It was failing my deployments. :(

The CNI plugin expects mtu to be an integer in the NetConf JSON, but
the Jinja template produced a string value causing pod sandbox creation
to fail with: cannot unmarshal string into Go struct field NetConf.mtu
of type int

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@agonzalezrh
Copy link
Copy Markdown
Contributor

@newgoliath use new chain image generated yesterday:

chained-2026-04-10

@newgoliath
Copy link
Copy Markdown
Author

I thought WK nixed this. Are we still going to use that ee?

@newgoliath newgoliath reopened this Apr 13, 2026
@newgoliath newgoliath closed this Apr 13, 2026
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.

2 participants