Skip to content

Relying on undefined behavior - parsing kubernetes resource names #716

@thockin

Description

@thockin

https://github.com/gocrane/crane/blob/main/pkg/utils/expression_prom_deafult_test.go#L18

The random suffix of a pod or other resource is not guaranteed to be 5 characters, nor is the characterset defined. Someone looked into the implementation details and took a dependency on them. This is brittle and could change at any time.

You should be using labels to extract metadata, not parsing the name. That's literally why they exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions