Open psjamesh opened 1 year ago
The warnings come from Yaml.newGsonCompatibleTypeDescription
which calls org.yaml.snakeyaml.TypeDescription.substituteProperty
for all x-kubernetes extensions, no matter if they exist for a given type or not (e.g. it is called for List
).
This is very annoying, because you get warnings despite everything being okay.
We'd be happy to take a PR to improve this behavior.
The problem seems that the extension names are not in "camelCase" format. They are used like
new String[] {
"x-kubernetes-embedded-resource",
"x-kubernetes-int-or-string",
"x-kubernetes-list-map-keys",
"x-kubernetes-list-type",
"x-kubernetes-map-type",
"x-kubernetes-preserve-unknown-fields",
};
Which are the GSON serialized-names of the fields in V1JSONSchemaProps, like:
public static final String SERIALIZED_NAME_X_KUBERNETES_INT_OR_STRING = "x-kubernetes-int-or-string";
@SerializedName(SERIALIZED_NAME_X_KUBERNETES_INT_OR_STRING)
private Boolean xKubernetesIntOrString;
but the org.yaml.snakeyaml.TypeDescription.substituteProperty
uses the field names as by reflection - e.g. it searched for fields named x-kubernetes-int-or-string
and etc... which are obviously not valid V1JSONSchemaProps field names
The Yaml.newGsonCompatibleTypeDescription()
should call not
desc.substituteProperty(
targetGsonAnnotation, field.getType(), getterMethod.getName(), setterMethod.getName());
but
desc.substituteProperty(
field.getName(), field.getType(), getterMethod.getName(), setterMethod.getName());
We've been observing this for a few months as well and it always seems concerning specially when using this in production systems. Is there going to be a fix for this? And is there at least a guarantee this won't be an issue?
Thank you
Hello. Unfortunately, currently the last version 19.0.0
has same issue.
As mentioned earlier, we'd be happy to take a PR to improve this if someone wants to make one.
Hi, I am interested in taking up this issue, can u please assign this issue to me?
Until fixed I use following workaround:
java.util.logging.Logger.getLogger("org.yaml.snakeyaml.introspector").setLevel(java.util.logging.Level.SEVERE)
hey i'm intrested to take this issue, would you like to assign this issue to me ?
Any updates on this ticket? Tried the workaround from the comment above but it didn't work for us
I believe the workaround may now need to use org.yaml.snakeyaml.internal
as the logger name. Note that the main problem with this workaround is it suppresses warnings for all callers of snakeyaml, e.g. if your application uses snakeyaml outside of the Kubernetes Java client.
Describe the bug When using the
Yaml.dump
method to serialize a K8S object (eg -V1Pod
) several warnings related to CRD schema attributes are output fromsnakeyaml
.The same issue occurs when using the
Yaml.loadAs
method (which is actually the method I am using in production).See example code and output below.
Client Version 18.0.1
Kubernetes Version N/A
Java Version Java 17
To Reproduce Run the YAML code example
Expected behavior The output should not contain warnings related to missing schema attributes for CRDs.
KubeConfig N/A
Operating System Linux
Additional context The (example) code I am running is below:
The output from the example code is below: