Skip to content

Audit APIs for Selector Field Semantics #28177

@danehans

Description

@danehans

API types that contain label selector fields, i.e. EndpointSelector, ServiceSelector, etc., have inconsistent behavior. Specifically, label selector fields should document semantics when the field is nil or empty. According to kubernetes/kubernetes#25836, nil and empty should be treated the same.

Write (or solicit API owners to write/update) API docs as needed. Flag anything that tries to differentiate nil from empty. For legacy selectors (map[string]string), nil and empty should always mean the same thing, and consider any that try to violate this. For modern selectors (metav1.LabelSelector), it may be OK to distinguish nil from empty but ONLY IF the field is a pointer.

Write an API convention for documenting this. Ideally, a blob of text that can be used on all fields.

Bonus: write an API linter that checks that any metav1.LabelSelector field has this text in the comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentCilium agent related.area/k8sImpacts the kubernetes API, or kubernetes -> cilium internals translation layers.kind/enhancementThis would improve or streamline existing functionality.staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions