Skip to content

Commit

Permalink
remove deprecated calls to ClusterName and ConfigMapsResourceLock
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten committed May 9, 2022
1 parent 509fe51 commit 6cdd63f
Show file tree
Hide file tree
Showing 31 changed files with 54 additions and 80 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- `datadogexporter`: Replace HistogramMode defined as string with enum.
- `pkg/translator/signalfx`: Change signalfx translator to expose To/From translator structs. (#9740)
- `transformprocessor`: Add parameter validation to `truncate_all` and `limit` functions. The `limit` parameter can no longer be negative. (#9783)
- `k8sclusterreceiver`: Removing `ClusterName` as per https://github.com/kubernetes/apimachinery/commit/430b920312ca0fa10eca95967764ff08f34083a3 (#9885)

### 🚩 Deprecations 🚩

Expand Down Expand Up @@ -51,6 +52,7 @@
- `tanzuobservabilityexporter`: Make metrics stanza in config be optional (#9098)
- `filelogreceiver`: Update Kubernetes examples to fix native OTel logs collection issue where 0 length logs cause errors (#9754)
- `logstransformprocessor`: Resolve node ordering to fix intermittent failures (#9761)
- `awsinsightreceiver`: Migrate from `ConfigMapsResourceLock` to `ConfigMapsLeasesResourceLock` as per https://github.com/kubernetes/client-go/commit/276ea3ed979947d7cdd4b3d708862245ddcd8883 (#9885)

## v0.50.0

Expand Down
7 changes: 0 additions & 7 deletions processor/k8sattributesprocessor/internal/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,6 @@ func (c *WatchClient) extractPodAttributes(pod *api_v1.Pod) map[string]string {
tags[tagNodeName] = pod.Spec.NodeName
}

if c.Rules.Cluster {
clusterName := pod.GetClusterName()
if clusterName != "" {
tags[conventions.AttributeK8SClusterName] = clusterName
}
}

for _, r := range c.Rules.Labels {
r.extractFromPodMetadata(pod.Labels, tags, "k8s.pod.labels.%s")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (f *FakeInformer) AddEventHandler(handler cache.ResourceEventHandler) {}
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, period time.Duration) {
}

func (f *FakeInformer) SetTransform(handler cache.TransformFunc) error {
return nil
}

func (f *FakeInformer) GetStore() cache.Store {
return cache.NewStore(func(obj interface{}) (string, error) { return "", nil })
}
Expand Down Expand Up @@ -131,6 +135,10 @@ func (f *NoOpInformer) AddEventHandler(handler cache.ResourceEventHandler) {}
func (f *NoOpInformer) AddEventHandlerWithResyncPeriod(handler cache.ResourceEventHandler, period time.Duration) {
}

func (f *NoOpInformer) SetTransform(handler cache.TransformFunc) error {
return nil
}

func (f *NoOpInformer) GetStore() cache.Store {
return cache.NewStore(func(obj interface{}) (string, error) { return "", nil })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (k *K8sAPIServer) init() error {
}

lock, err := resourcelock.New(
resourcelock.ConfigMapsResourceLock,
resourcelock.ConfigMapsLeasesResourceLock,
lockNamespace, lockName,
clientSet.CoreV1(),
clientSet.CoordinationV1(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ func getResourceForClusterResourceQuota(rq *quotav1.ClusterResourceQuota) *resou
return &resourcepb.Resource{
Type: k8sType,
Labels: map[string]string{
k8sKeyClusterResourceQuotaUID: string(rq.UID),
k8sKeyClusterResourceQuotaName: rq.Name,
conventions.AttributeK8SClusterName: rq.ClusterName,
k8sKeyClusterResourceQuotaUID: string(rq.UID),
k8sKeyClusterResourceQuotaName: rq.Name,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ func TestClusterRequestQuotaMetrics(t *testing.T) {
func newMockClusterResourceQuota(id string) *quotav1.ClusterResourceQuota {
return &quotav1.ClusterResourceQuota{
ObjectMeta: v1.ObjectMeta{
Name: "test-clusterquota-" + id,
UID: types.UID("test-clusterquota-" + id + "-uid"),
ClusterName: "test-openshift-cluster",
Name: "test-clusterquota-" + id,
UID: types.UID("test-clusterquota-" + id + "-uid"),
},
Status: quotav1.ClusterResourceQuotaStatus{
Total: corev1.ResourceQuotaStatus{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,9 @@ func TestDataCollectorSyncMetadata(t *testing.T) {
metadataStore: &metadataStore{},
resource: &corev1.ReplicationController{
ObjectMeta: v1.ObjectMeta{
Name: "test-replicationcontroller-1",
Namespace: "test-namespace",
UID: types.UID("test-replicationcontroller-1-uid"),
ClusterName: "test-cluster",
Name: "test-replicationcontroller-1",
Namespace: "test-namespace",
UID: types.UID("test-replicationcontroller-1-uid"),
},
},
want: map[metadata.ResourceID]*KubernetesMetadata{
Expand Down
2 changes: 0 additions & 2 deletions receiver/k8sclusterreceiver/internal/collection/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func getResourceForCronJob(cj *batchv1.CronJob) *resourcepb.Resource {
conventions.AttributeK8SCronJobUID: string(cj.UID),
conventions.AttributeK8SCronJobName: cj.Name,
conventions.AttributeK8SNamespaceName: cj.Namespace,
conventions.AttributeK8SClusterName: cj.ClusterName,
},
}
}
Expand All @@ -95,7 +94,6 @@ func getResourceForCronJobBeta(cj *batchv1beta1.CronJob) *resourcepb.Resource {
conventions.AttributeK8SCronJobUID: string(cj.UID),
conventions.AttributeK8SCronJobName: cj.Name,
conventions.AttributeK8SNamespaceName: cj.Namespace,
conventions.AttributeK8SClusterName: cj.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ func TestCronJobMetadata(t *testing.T) {
func newCronJob(id string) *batchv1.CronJob {
return &batchv1.CronJob{
ObjectMeta: v1.ObjectMeta{
Name: "test-cronjob-" + id,
Namespace: "test-namespace",
UID: types.UID("test-cronjob-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-cronjob-" + id,
Namespace: "test-namespace",
UID: types.UID("test-cronjob-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func getResourceForDaemonSet(ds *appsv1.DaemonSet) *resourcepb.Resource {
conventions.AttributeK8SDaemonSetUID: string(ds.UID),
conventions.AttributeK8SDaemonSetName: ds.Name,
conventions.AttributeK8SNamespaceName: ds.Namespace,
conventions.AttributeK8SClusterName: ds.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ func TestDaemonsetMetrics(t *testing.T) {
func newDaemonset(id string) *appsv1.DaemonSet {
return &appsv1.DaemonSet{
ObjectMeta: v1.ObjectMeta{
Name: "test-daemonset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-daemonset-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-daemonset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-daemonset-" + id + "-uid"),
},
Status: appsv1.DaemonSetStatus{
CurrentNumberScheduled: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func getResourceForDeployment(dep *appsv1.Deployment) *resourcepb.Resource {
conventions.AttributeK8SDeploymentUID: string(dep.UID),
conventions.AttributeK8SDeploymentName: dep.Name,
conventions.AttributeK8SNamespaceName: dep.Namespace,
conventions.AttributeK8SClusterName: dep.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ func newDeployment(id string) *appsv1.Deployment {
desired := int32(10)
return &appsv1.Deployment{
ObjectMeta: v1.ObjectMeta{
Name: "test-deployment-" + id,
Namespace: "test-namespace",
UID: types.UID("test-deployment-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-deployment-" + id,
Namespace: "test-namespace",
UID: types.UID("test-deployment-" + id + "-uid"),
},
Spec: appsv1.DeploymentSpec{
Replicas: &desired,
Expand Down
1 change: 0 additions & 1 deletion receiver/k8sclusterreceiver/internal/collection/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func getResourceForHPA(hpa *autoscalingv2beta2.HorizontalPodAutoscaler) *resourc
k8sKeyHPAUID: string(hpa.UID),
k8sKeyHPAName: hpa.Name,
conventions.AttributeK8SNamespaceName: hpa.Namespace,
conventions.AttributeK8SClusterName: hpa.ClusterName,
},
}
}
Expand Down
7 changes: 3 additions & 4 deletions receiver/k8sclusterreceiver/internal/collection/hpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ func newHPA(id string) *autoscalingv2beta2.HorizontalPodAutoscaler {
minReplicas := int32(2)
return &autoscalingv2beta2.HorizontalPodAutoscaler{
ObjectMeta: v1.ObjectMeta{
Name: "test-hpa-" + id,
Namespace: "test-namespace",
UID: types.UID("test-hpa-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-hpa-" + id,
Namespace: "test-namespace",
UID: types.UID("test-hpa-" + id + "-uid"),
},
Status: autoscalingv2beta2.HorizontalPodAutoscalerStatus{
CurrentReplicas: 5,
Expand Down
1 change: 0 additions & 1 deletion receiver/k8sclusterreceiver/internal/collection/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func getResourceForJob(j *batchv1.Job) *resourcepb.Resource {
conventions.AttributeK8SJobUID: string(j.UID),
conventions.AttributeK8SJobName: j.Name,
conventions.AttributeK8SNamespaceName: j.Namespace,
conventions.AttributeK8SClusterName: j.ClusterName,
},
}
}
Expand Down
7 changes: 3 additions & 4 deletions receiver/k8sclusterreceiver/internal/collection/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ func newJob(id string) *batchv1.Job {
c := int32(10)
return &batchv1.Job{
ObjectMeta: v1.ObjectMeta{
Name: "test-job-" + id,
Namespace: "test-namespace",
UID: types.UID("test-job-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-job-" + id,
Namespace: "test-namespace",
UID: types.UID("test-job-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func getResourceForNamespace(ns *corev1.Namespace) *resourcepb.Resource {
Labels: map[string]string{
k8sKeyNamespaceUID: string(ns.UID),
conventions.AttributeK8SNamespaceName: ns.Namespace,
conventions.AttributeK8SClusterName: ns.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ func TestNamespaceMetrics(t *testing.T) {
func newNamespace(id string) *corev1.Namespace {
return &corev1.Namespace{
ObjectMeta: v1.ObjectMeta{
Name: "test-namespace-" + id,
Namespace: "test-namespace",
UID: types.UID("test-namespace-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-namespace-" + id,
Namespace: "test-namespace",
UID: types.UID("test-namespace-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
5 changes: 2 additions & 3 deletions receiver/k8sclusterreceiver/internal/collection/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ func getResourceForNode(node *corev1.Node) *resourcepb.Resource {
return &resourcepb.Resource{
Type: k8sType,
Labels: map[string]string{
conventions.AttributeK8SNodeUID: string(node.UID),
conventions.AttributeK8SNodeName: node.Name,
conventions.AttributeK8SClusterName: node.ClusterName,
conventions.AttributeK8SNodeUID: string(node.UID),
conventions.AttributeK8SNodeName: node.Name,
},
}
}
Expand Down
10 changes: 4 additions & 6 deletions receiver/k8sclusterreceiver/internal/collection/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ func newNode(id string) *corev1.Node {
if featuregate.GetRegistry().IsEnabled(reportCPUMetricsAsDoubleFeatureGateID) {
return &corev1.Node{
ObjectMeta: v1.ObjectMeta{
Name: "test-node-" + id,
UID: types.UID("test-node-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-node-" + id,
UID: types.UID("test-node-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand All @@ -130,9 +129,8 @@ func newNode(id string) *corev1.Node {
}
return &corev1.Node{
ObjectMeta: v1.ObjectMeta{
Name: "test-node-" + id,
UID: types.UID("test-node-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-node-" + id,
UID: types.UID("test-node-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
1 change: 0 additions & 1 deletion receiver/k8sclusterreceiver/internal/collection/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func getResourceForPod(pod *corev1.Pod) *resourcepb.Resource {
conventions.AttributeK8SPodName: pod.Name,
conventions.AttributeK8SNodeName: pod.Spec.NodeName,
conventions.AttributeK8SNamespaceName: pod.Namespace,
conventions.AttributeK8SClusterName: pod.ClusterName,
},
}
}
Expand Down
7 changes: 3 additions & 4 deletions receiver/k8sclusterreceiver/internal/collection/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ func TestPodAndContainerMetricsReportCPUMetricsAsDouble(t *testing.T) {
func newPodWithContainer(id string, spec *corev1.PodSpec, status *corev1.PodStatus) *corev1.Pod {
return &corev1.Pod{
ObjectMeta: v1.ObjectMeta{
Name: "test-pod-" + id,
Namespace: "test-namespace",
UID: types.UID("test-pod-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-pod-" + id,
Namespace: "test-namespace",
UID: types.UID("test-pod-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func getResourceForReplicaSet(rs *appsv1.ReplicaSet) *resourcepb.Resource {
conventions.AttributeK8SReplicaSetUID: string(rs.UID),
conventions.AttributeK8SReplicaSetName: rs.Name,
conventions.AttributeK8SNamespaceName: rs.Namespace,
conventions.AttributeK8SClusterName: rs.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ func TestReplicasetMetrics(t *testing.T) {
func newReplicaSet(id string) *appsv1.ReplicaSet {
return &appsv1.ReplicaSet{
ObjectMeta: v1.ObjectMeta{
Name: "test-replicaset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-replicaset-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-replicaset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-replicaset-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func getResourceForReplicationController(rc *corev1.ReplicationController) *reso
k8sKeyReplicationControllerUID: string(rc.UID),
k8sKeyReplicationControllerName: rc.Name,
conventions.AttributeK8SNamespaceName: rc.Namespace,
conventions.AttributeK8SClusterName: rc.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func getResourceForResourceQuota(rq *corev1.ResourceQuota) *resourcepb.Resource
k8sKeyResourceQuotaUID: string(rq.UID),
k8sKeyResourceQuotaName: rq.Name,
conventions.AttributeK8SNamespaceName: rq.Namespace,
conventions.AttributeK8SClusterName: rq.ClusterName,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ func TestRequestQuotaMetrics(t *testing.T) {
func newResourceQuota(id string) *corev1.ResourceQuota {
return &corev1.ResourceQuota{
ObjectMeta: v1.ObjectMeta{
Name: "test-resourcequota-" + id,
UID: types.UID("test-resourcequota-" + id + "-uid"),
ClusterName: "test-cluster",
Namespace: "test-namespace",
Name: "test-resourcequota-" + id,
UID: types.UID("test-resourcequota-" + id + "-uid"),
Namespace: "test-namespace",
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func getResourceForStatefulSet(ss *appsv1.StatefulSet) *resourcepb.Resource {
conventions.AttributeK8SStatefulSetUID: string(ss.UID),
conventions.AttributeK8SStatefulSetName: ss.Name,
conventions.AttributeK8SNamespaceName: ss.Namespace,
conventions.AttributeK8SClusterName: ss.ClusterName,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ func newStatefulset(id string) *appsv1.StatefulSet {
desired := int32(10)
return &appsv1.StatefulSet{
ObjectMeta: v1.ObjectMeta{
Name: "test-statefulset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-statefulset-" + id + "-uid"),
ClusterName: "test-cluster",
Name: "test-statefulset-" + id,
Namespace: "test-namespace",
UID: types.UID("test-statefulset-" + id + "-uid"),
Labels: map[string]string{
"foo": "bar",
"foo1": "",
Expand Down
1 change: 0 additions & 1 deletion receiver/k8seventsreceiver/k8s_event_to_logdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func k8sEventToLogData(logger *zap.Logger, ev *corev1.Event) plog.Logs {
resourceAttrs := rl.Resource().Attributes()
resourceAttrs.EnsureCapacity(totalResourceAttributes)

resourceAttrs.InsertString(semconv.AttributeK8SClusterName, ev.ObjectMeta.ClusterName)
resourceAttrs.InsertString(semconv.AttributeK8SNodeName, ev.Source.Host)

// Attributes related to the object causing the event.
Expand Down

0 comments on commit 6cdd63f

Please sign in to comment.