Skip to content

Fix NetworkAttachmentDefinition config to produce valid JSON#15

Closed
rut31337 wants to merge 1 commit into
mainfrom
fix/network-config-json
Closed

Fix NetworkAttachmentDefinition config to produce valid JSON#15
rut31337 wants to merge 1 commit into
mainfrom
fix/network-config-json

Conversation

@rut31337
Copy link
Copy Markdown

Summary

Fix create_network.yaml to produce valid JSON for the NetworkAttachmentDefinition spec.config field.

Problem

The _config variable was defined as a YAML block scalar containing a Python dict literal:

_config: >-
  {'cniVersion':'0.3.1','type':'ovn-k8s-cni-overlay','topology':'layer2', ...}

When piped through | to_json, Jinja treats this as a string (not a dict) and JSON-encodes the string itself — wrapping it in quotes rather than converting key-value pairs to JSON. The Multus admission webhook rejects the result:

admission webhook "multus-validating-config.k8s.io" denied the request:
configuration string is not in JSON format

Fix

Define _config as a proper YAML dict so to_json serializes it correctly:

_config:
  cniVersion: "0.3.1"
  type: ovn-k8s-cni-overlay
  topology: layer2
  name: "{{ _network.name }}{{ guid }}"
  ...

Observed on

  • event1.apps.ocpv-infra02.wdc07.infra.demo.redhat.com — job 1139 (lb2759-agentic-aiops-aap-cnv)
  • EE: quay.io/agnosticd/ee-multicloud:chained-2026-04-01

The _config variable was defined as a YAML block scalar containing a
Python dict literal (single quotes, unquoted integers). When piped
through `to_json`, Jinja treated it as a string and JSON-encoded the
string itself rather than converting a dict to JSON. The result was
not valid JSON, causing the Multus admission webhook to reject it:

  admission webhook "multus-validating-config.k8s.io" denied the
  request: configuration string is not in JSON format

Fix by defining _config as a proper YAML dict so `to_json` produces
valid JSON output.
Copy link
Copy Markdown

@perryrivera1 perryrivera1 left a comment

Choose a reason for hiding this comment

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

lgtm

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.

let's try first ansible 2.18

@rut31337 rut31337 closed this Apr 10, 2026
@rut31337 rut31337 deleted the fix/network-config-json branch April 10, 2026 20:43
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.

3 participants