kubernetes: api server's ValidateCustomResource failed for map with additionalProperties of string type
What happened:
Trying to use k8s.io/apiextensions-apiserver/pkg/apiserver/validation to validate a YAML file with OpenAPI.
The YAML file contains a map:
labels:
a: b
And the openAPIV3Schema generated by kubebuilder contains below logic:
labels:
additionalProperties:
type: string
description: 'xxx.'
type: object
When I use this openAPIV3Schema to verify my YAML file, it will have errors:
unexpected validation error for map[field:map[a:b]]: [field: Invalid value: "a": field.a in body is a forbidden property]
What you expected to happen:
It should not throw error
How to reproduce it (as minimally and precisely as possible):
I wrote a unit test: https://github.com/kubernetes/apiextensions-apiserver/pull/52/files, this test is failing.
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): 1.20 - Cloud provider or hardware configuration: None.
- OS (e.g:
cat /etc/os-release): - Kernel (e.g.
uname -a): - Install tools:
- Network plugin and version (if this is a network-related bug):
- Others:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (8 by maintainers)
Gentle ping!
Any updates on this? Is this by design?