Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Yaml.dump and Yaml.loadAs log warnings related to V1JSONSchemaProps #2741

@psjamesh

Description

@psjamesh

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 from snakeyaml.

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:

public class YamlExample {
    public static void main(String[] args) throws IOException, ApiException, ClassNotFoundException {
        V1Pod pod =
                new V1PodBuilder()
                        .withNewMetadata()
                        .withName("apod")
                        .endMetadata()
                        .withNewSpec()
                        .addNewContainer()
                        .withName("www")
                        .withImage("nginx")
                        .withNewResources()
                        .withLimits(new HashMap<>())
                        .endResources()
                        .endContainer()
                        .endSpec()
                        .build();

        System.out.println(Yaml.dump(pod));
    }
}

The output from the example code is below:

Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-embedded-resource
Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-int-or-string
Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-list-map-keys
Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-list-type
Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-map-type
Jul 27, 2023 1:23:33 PM org.yaml.snakeyaml.internal.Logger warn
WARNING: Failed to find field for io.kubernetes.client.openapi.models.V1JSONSchemaProps.x-kubernetes-preserve-unknown-fields
metadata:
  name: apod
spec:
  containers:
  - image: nginx
    name: www
    resources:
      limits: {}


Process finished with exit code 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions