• Kubernetes Submit Queue's avatar
    Merge pull request #45294 from liggitt/proto-slices · 217513e2
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Remove null -> [] slice hack
    
    Closes #44593
    
    When 1.6 added protobuf storage, the storage layer lost the ability to persist slice fields with empty but non-null values.
    
    As a workaround, we tried to convert empty slice fields to `[]`, rather than `null`. Compressing `null` -> `[]` was just as much of an API breakage as `[]` -> `null`, but was hoped to cause fewer problems in clients that don't do null checks.
    
    Because of conversion optimizations around converting lists of objects, the `null` -> `[]` hack was discovered to only apply to individual get requests, not to a list of objects. 1.6 and 1.7 was released with this behavior, and the world didn't explode. 1.7 documented the breaking API change that `null` and `[]` should be considered equivalent, unless otherwise noted on a particular field.
    
    This PR:
    
    * Reverts the earlier attempt (https://github.com/kubernetes/kubernetes/pull/43422) at ensuring non-null json slice output in conversion
    * Makes results of `get` consistent with the results of `list` (which helps naive clients that do deepequal comparisons of objects obtained via list/watch and get), and allows empty slice fields to be returned as `null`
    
    ```release-note
    Protobuf serialization does not distinguish between `[]` and `null`.
    API fields previously capable of storing and returning either `[]` and `null` via JSON API requests (for example, the Endpoints `subsets` field) can now store only `null` when created using the protobuf content-type or stored in etcd using protobuf serialization (the default in 1.6+). JSON API clients should tolerate `null` values for such fields, and treat `null` and `[]` as equivalent in meaning unless specifically documented otherwise for a particular field.
    ```
    217513e2
Name
Last commit
Last update
..
cmd/kube-scheduler Loading commit data...
pkg Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...