Skip to content

[k8sattributes] Revisit regex based metadata extraction #44831

@ChrsMark

Description

@ChrsMark

As it was mentioned at #23067 (comment) recently, we should ensure that metadata extraction is consistent for different types of workloads.

Right now we use some regexp patterns for extracting owners' names:

// Extract replicaset name from the pod name. Pod name is created using
// format: [deployment-name]-[Random-String-For-ReplicaSet]
var rRegex = regexp.MustCompile(`^(.*)-[0-9a-zA-Z]+$`)
// Extract CronJob name from the Job name. Job name is created using
// format: [cronjob-name]-[time-hash-int]
var cronJobRegex = regexp.MustCompile(`^(.*)-\d+$`)
// Extract Deployment name from the ReplicaSet name. Deployment name is created using
// format: [deployment-name]-[hash]
var deploymentHashSuffixPattern = regexp.MustCompile(`^[a-z0-9]{10}$`)

#42534 added support for extracting the deployment name from the replicaset's name behind a setting. But for other workloads that's not configurable ie:

parts := c.cronJobRegex.FindStringSubmatch(ref.Name)

We should revisit this and aim for consistency.

As it was also mentioned in the other issue this logic is not guaranteed: kubernetes/kubernetes#121687 (comment). Hence we should also evaluate if we actually want this pattern.

FYI @dashpole @JeffLuoo

Metadata

Metadata

Assignees

Labels

component-stability-phase-1Part of the Phase 1 Component Stability Project.never staleIssues marked with this label will be never staled and automatically removedpriority:p1Highprocessor/k8sattributesk8s Attributes processor

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions