Skip to content

fix(schema): accept an integer netmask in network config v1 - #6998

Open
sbraz wants to merge 1 commit into
canonical:mainfrom
sbraz:network_v1_schema_netmask_integer
Open

fix(schema): accept an integer netmask in network config v1#6998
sbraz wants to merge 1 commit into
canonical:mainfrom
sbraz:network_v1_schema_netmask_integer

Conversation

@sbraz

@sbraz sbraz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Proposed Commit Message

fix(schema): accept an integer netmask in network config v1

A config drive setting an IPv6 route netmask as an integer produces this,
even though the route is applied correctly:
```
schema.py[WARNING]: network-config-v1 failed schema validation! You may run 'sudo cloud-init schema --system' to check the details.
```
```
# cloud-init schema --system
Error: Cloud config schema errors: config.0.subnets.1.routes.0.netmask: 128 is not of type 'string'
```

Nothing that reads the value requires a string:

- `_normalize_net_keys()` passes `netmask`, for subnets and routes, to
  `ipv4_mask_to_net_prefix()` or `ipv6_mask_to_net_prefix()`, which document
  accepting an integer or a string representation of one.
- `test_ipv6_static_routes_ip_cmd` renders a v1 config containing both
  `"netmask": 24` as an integer and `"netmask": "32"` as a string.

Accept an integer alongside a string, for subnets and routes, and reword the
description to cover IPv6.

Test Steps

# /tmp/net-v1.yaml
network:
  version: 1
  config:
    - type: physical
      name: eth0
      subnets:
        - type: static6
          address: "2001:db8::1/128"
          gateway: "2001:db8::2"
          routes:
            - network: "2001:db8:1::"
              netmask: 128
              gateway: "2001:db8::2"

Before:

$ cloud-init schema -t network-config -c /tmp/net-v1.yaml
Error: Cloud config schema errors: network.config.0.subnets.0.routes.0.netmask: 128 is not of type 'string'
Error: Invalid schema: network-config

After:

$ cloud-init schema -t network-config -c /tmp/net-v1.yaml
Valid schema /tmp/net-v1.yaml

Unit tests:

$ tox -e py3 -- tests/unittests/config/test_schema.py
156 passed, 2 skipped

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@github-actions github-actions Bot added the documentation This Pull Request changes documentation label Aug 12, 2026
A config drive setting an IPv6 route netmask as an integer produces this,
even though the route is applied correctly:
```
schema.py[WARNING]: network-config-v1 failed schema validation! You may run 'sudo cloud-init schema --system' to check the details.
```
```
# cloud-init schema --system
Error: Cloud config schema errors: config.0.subnets.1.routes.0.netmask: 128 is not of type 'string'
```

Nothing that reads the value requires a string:

- `_normalize_net_keys()` passes `netmask`, for subnets and routes, to
  `ipv4_mask_to_net_prefix()` or `ipv6_mask_to_net_prefix()`, which document
  accepting an integer or a string representation of one.
- `test_ipv6_static_routes_ip_cmd` renders a v1 config containing both
  `"netmask": 24` as an integer and `"netmask": "32"` as a string.

Accept an integer alongside a string, for subnets and routes, and reword the
description to cover IPv6.
@sbraz
sbraz force-pushed the network_v1_schema_netmask_integer branch from 69f12b4 to cdb4644 Compare August 12, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This Pull Request changes documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant