Skip to content

API: support adding new keys to listType=map #132524

Open
@pohly

Description

@pohly

What would you like to be added?

When an API uses +listType=map with a certain set of +listMapKeys, it should be possible to extend the API such that new, optional fields can be used as keys.

Currently this is rejected by SSA with:

            failed to create typed patch object (testdra-all-resourceclaimdevicestatus-5d6xm/my-pod-my-resource; resource.k8s.io/v1beta1, Kind=ResourceClaim): .status.devices: element 0: associative list with keys has an element that omits key field "shareUID" (and doesn't have default value)
            {
                ErrStatus: 
                    code: 500
                    message: 'failed to create typed patch object (testdra-all-resourceclaimdevicestatus-5d6xm/my-pod-my-resource;
                      resource.k8s.io/v1beta1, Kind=ResourceClaim): .status.devices: element 0: associative
                      list with keys has an element that omits key field "shareUID" (and doesn''t have
                      default value)'
                    metadata: {}
                    status: Failure,
            }

Why is this needed?

kubernetes/enhancements#4817 (beta in 1.34) added:

// Devices contains the status of each device allocated for this
// claim, as reported by the driver. This can include driver-specific
// information. Entries are owned by their respective drivers.
//
// +optional
// +listType=map
// +listMapKey=driver
// +listMapKey=device
// +listMapKey=pool
// +featureGate=DRAResourceClaimDeviceStatus
Devices []AllocatedDeviceStatus `json:"devices,omitempty" protobuf:"bytes,4,opt,name=devices"`

Now kubernetes/enhancements#5075 needs to extend the driver/pool/device triplet with an optional "share ID".

Alternatives:

  • encode the additional share ID in the device string: ugly
  • make the new field required, with empty string as default: also ugly (alpha-level field always gets stored and shown to users even when empty), doesn't work completely after an upgrade (deleting existing entry without the new key in managed fields not possible)

/cc @sunya-ch @liggitt @jpbetz
/sig api-machinery

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions