Skip to content

CustomResources dropping "null" values from arrays #98080

@caseydavenport

Description

@caseydavenport

What happened:

While attempting to work around #98079, I encountered an issue where data was not preserved when writing a custom resource instance to the apiserver with kubectl.

Specifically, I am using a CRD that has a properly which is an array of values which can either be an integer, or null:

spec:
  properties:
    allocations:
      items:
        nullable: true
        type: integer
      type: array

When using kubectl to modify the resource, all of the "null" values are lost upon write. So, if I attempt to write a resource with the following:

allocations:
- 1
- 5
- null
- null

It is written successfully. However, when I query the resource from the API afterwards, this is what I get back:

allocations:
- 1
- 5

The null entries have been lost.

What you expected to happen:

The null entries in the array should be maintained.

How to reproduce it (as minimally and precisely as possible):

Create a CustomResourceDefinition with a property like the one specified above, and create an instance of it (you may need to pass --validate=false in order to bypass the bug in #98079).

Notice that null values are removed from the array.

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:19:45Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Also reproduced on master by @liggitt

CC @sttts @apelisse

/sig api-machinery

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.priority/critical-urgentHighest priority. Must be actively worked on as someone's top priority right now.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions