From c236599737ba31238d0c6059cd9d1f9e9a9cc563 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Thu, 27 Jan 2022 20:16:06 +0530 Subject: [PATCH 1/7] Otel-collector-contrib-7386 removing batch/v1beta1 and autoscaling/v2beta1 k8s api from receiver/k8scluster --- .../internal/collection/collector.go | 7 +++---- .../k8sclusterreceiver/internal/collection/cronjobs.go | 8 ++++---- .../internal/collection/cronjobs_test.go | 10 +++++----- receiver/k8sclusterreceiver/internal/collection/hpa.go | 2 +- .../k8sclusterreceiver/internal/collection/hpa_test.go | 2 +- receiver/k8sclusterreceiver/watcher.go | 5 ++--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/receiver/k8sclusterreceiver/internal/collection/collector.go b/receiver/k8sclusterreceiver/internal/collection/collector.go index 6039aa944415..b64da9148150 100644 --- a/receiver/k8sclusterreceiver/internal/collection/collector.go +++ b/receiver/k8sclusterreceiver/internal/collection/collector.go @@ -23,9 +23,8 @@ import ( "go.opentelemetry.io/collector/model/pdata" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - "k8s.io/api/autoscaling/v2beta1" + "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" - batchv1beta1 "k8s.io/api/batch/v1beta1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -146,7 +145,7 @@ func (dc *DataCollector) SyncMetrics(obj interface{}) { rm = getMetricsForStatefulSet(o) case *batchv1.Job: rm = getMetricsForJob(o) - case *batchv1beta1.CronJob: + case *batchv1.CronJob: rm = getMetricsForCronJob(o) case *v2beta1.HorizontalPodAutoscaler: rm = getMetricsForHPA(o) @@ -183,7 +182,7 @@ func (dc *DataCollector) SyncMetadata(obj interface{}) map[metadata.ResourceID]* km = getMetadataForStatefulSet(o) case *batchv1.Job: km = getMetadataForJob(o) - case *batchv1beta1.CronJob: + case *batchv1.CronJob: km = getMetadataForCronJob(o) case *v2beta1.HorizontalPodAutoscaler: km = getMetadataForHPA(o) diff --git a/receiver/k8sclusterreceiver/internal/collection/cronjobs.go b/receiver/k8sclusterreceiver/internal/collection/cronjobs.go index e8a33f8e88a7..7f9bfbf27b40 100644 --- a/receiver/k8sclusterreceiver/internal/collection/cronjobs.go +++ b/receiver/k8sclusterreceiver/internal/collection/cronjobs.go @@ -18,7 +18,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" - batchv1beta1 "k8s.io/api/batch/v1beta1" + batchv1 "k8s.io/api/batch/v1" metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/utils" @@ -37,7 +37,7 @@ var activeJobs = &metricspb.MetricDescriptor{ Type: metricspb.MetricDescriptor_GAUGE_INT64, } -func getMetricsForCronJob(cj *batchv1beta1.CronJob) []*resourceMetrics { +func getMetricsForCronJob(cj *batchv1.CronJob) []*resourceMetrics { metrics := []*metricspb.Metric{ { MetricDescriptor: activeJobs, @@ -55,7 +55,7 @@ func getMetricsForCronJob(cj *batchv1beta1.CronJob) []*resourceMetrics { } } -func getResourceForCronJob(cj *batchv1beta1.CronJob) *resourcepb.Resource { +func getResourceForCronJob(cj *batchv1.CronJob) *resourcepb.Resource { return &resourcepb.Resource{ Type: k8sType, Labels: map[string]string{ @@ -67,7 +67,7 @@ func getResourceForCronJob(cj *batchv1beta1.CronJob) *resourcepb.Resource { } } -func getMetadataForCronJob(cj *batchv1beta1.CronJob) map[metadata.ResourceID]*KubernetesMetadata { +func getMetadataForCronJob(cj *batchv1.CronJob) map[metadata.ResourceID]*KubernetesMetadata { rm := getGenericMetadata(&cj.ObjectMeta, k8sKindCronJob) rm.metadata[cronJobKeySchedule] = cj.Spec.Schedule rm.metadata[cronJobKeyConcurrencyPolicy] = string(cj.Spec.ConcurrencyPolicy) diff --git a/receiver/k8sclusterreceiver/internal/collection/cronjobs_test.go b/receiver/k8sclusterreceiver/internal/collection/cronjobs_test.go index 6582e55ffce3..1b76cd6fe6e3 100644 --- a/receiver/k8sclusterreceiver/internal/collection/cronjobs_test.go +++ b/receiver/k8sclusterreceiver/internal/collection/cronjobs_test.go @@ -19,7 +19,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" "github.com/stretchr/testify/require" - batchv1beta1 "k8s.io/api/batch/v1beta1" + batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -74,8 +74,8 @@ func TestCronJobMetadata(t *testing.T) { ) } -func newCronJob(id string) *batchv1beta1.CronJob { - return &batchv1beta1.CronJob{ +func newCronJob(id string) *batchv1.CronJob { + return &batchv1.CronJob{ ObjectMeta: v1.ObjectMeta{ Name: "test-cronjob-" + id, Namespace: "test-namespace", @@ -86,11 +86,11 @@ func newCronJob(id string) *batchv1beta1.CronJob { "foo1": "", }, }, - Spec: batchv1beta1.CronJobSpec{ + Spec: batchv1.CronJobSpec{ Schedule: "schedule", ConcurrencyPolicy: "concurrency_policy", }, - Status: batchv1beta1.CronJobStatus{ + Status: batchv1.CronJobStatus{ Active: []corev1.ObjectReference{{}, {}}, }, } diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa.go b/receiver/k8sclusterreceiver/internal/collection/hpa.go index 47ee703442df..8df359f2fddc 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa.go @@ -18,7 +18,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" - "k8s.io/api/autoscaling/v2beta1" + "k8s.io/api/autoscaling/v2beta2" metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/utils" diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go index 65e7c8f02679..10ef3501a357 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go @@ -19,7 +19,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" "github.com/stretchr/testify/require" - "k8s.io/api/autoscaling/v2beta1" + "k8s.io/api/autoscaling/v2beta2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index 0578310b81fd..f8d326b45097 100644 --- a/receiver/k8sclusterreceiver/watcher.go +++ b/receiver/k8sclusterreceiver/watcher.go @@ -28,9 +28,8 @@ import ( "go.uber.org/atomic" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - "k8s.io/api/autoscaling/v2beta1" + "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" - batchv1beta1 "k8s.io/api/batch/v1beta1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/informers" @@ -98,7 +97,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() { rw.setupInformers(&appsv1.ReplicaSet{}, factory.Apps().V1().ReplicaSets().Informer()) rw.setupInformers(&appsv1.StatefulSet{}, factory.Apps().V1().StatefulSets().Informer()) rw.setupInformers(&batchv1.Job{}, factory.Batch().V1().Jobs().Informer()) - rw.setupInformers(&batchv1beta1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) + rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) rw.setupInformers(&v2beta1.HorizontalPodAutoscaler{}, factory.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer(), ) From 4010688f58d3a3ddf99f50e7a555d0c93d70e415 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Thu, 27 Jan 2022 23:18:43 +0530 Subject: [PATCH 2/7] Otel-collector-contrib-7386 replacing autoscaling/v2beta1 with autoscaling/v2beta2 k8s api from receiver/k8scluster --- .../k8sclusterreceiver/internal/collection/collector.go | 6 +++--- receiver/k8sclusterreceiver/internal/collection/hpa.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/receiver/k8sclusterreceiver/internal/collection/collector.go b/receiver/k8sclusterreceiver/internal/collection/collector.go index b64da9148150..8debcd5fc3f7 100644 --- a/receiver/k8sclusterreceiver/internal/collection/collector.go +++ b/receiver/k8sclusterreceiver/internal/collection/collector.go @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/model/pdata" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - "k8s.io/api/autoscaling/v2beta2" + v2beta2 "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -147,7 +147,7 @@ func (dc *DataCollector) SyncMetrics(obj interface{}) { rm = getMetricsForJob(o) case *batchv1.CronJob: rm = getMetricsForCronJob(o) - case *v2beta1.HorizontalPodAutoscaler: + case *v2beta2.HorizontalPodAutoscaler: rm = getMetricsForHPA(o) case *quotav1.ClusterResourceQuota: rm = getMetricsForClusterResourceQuota(o) @@ -184,7 +184,7 @@ func (dc *DataCollector) SyncMetadata(obj interface{}) map[metadata.ResourceID]* km = getMetadataForJob(o) case *batchv1.CronJob: km = getMetadataForCronJob(o) - case *v2beta1.HorizontalPodAutoscaler: + case *v2beta2.HorizontalPodAutoscaler: km = getMetadataForHPA(o) } diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa.go b/receiver/k8sclusterreceiver/internal/collection/hpa.go index 8df359f2fddc..16a5cd903d2c 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa.go @@ -18,7 +18,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" - "k8s.io/api/autoscaling/v2beta2" + v2beta2 "k8s.io/api/autoscaling/v2beta2" metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/utils" @@ -52,7 +52,7 @@ var hpaDesiredReplicasMetric = &metricspb.MetricDescriptor{ Type: metricspb.MetricDescriptor_GAUGE_INT64, } -func getMetricsForHPA(hpa *v2beta1.HorizontalPodAutoscaler) []*resourceMetrics { +func getMetricsForHPA(hpa *v2beta2.HorizontalPodAutoscaler) []*resourceMetrics { metrics := []*metricspb.Metric{ { MetricDescriptor: hpaMaxReplicasMetric, @@ -88,7 +88,7 @@ func getMetricsForHPA(hpa *v2beta1.HorizontalPodAutoscaler) []*resourceMetrics { } } -func getResourceForHPA(hpa *v2beta1.HorizontalPodAutoscaler) *resourcepb.Resource { +func getResourceForHPA(hpa *v2beta2.HorizontalPodAutoscaler) *resourcepb.Resource { return &resourcepb.Resource{ Type: k8sType, Labels: map[string]string{ @@ -100,7 +100,7 @@ func getResourceForHPA(hpa *v2beta1.HorizontalPodAutoscaler) *resourcepb.Resourc } } -func getMetadataForHPA(hpa *v2beta1.HorizontalPodAutoscaler) map[metadata.ResourceID]*KubernetesMetadata { +func getMetadataForHPA(hpa *v2beta2.HorizontalPodAutoscaler) map[metadata.ResourceID]*KubernetesMetadata { return map[metadata.ResourceID]*KubernetesMetadata{ metadata.ResourceID(hpa.UID): getGenericMetadata(&hpa.ObjectMeta, "HPA"), } From 06ef12f3c68a041361cb7e456623ce83e5660679 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Thu, 27 Jan 2022 23:47:41 +0530 Subject: [PATCH 3/7] Otel-collector-contrib-7386 replacing autoscaling/v2beta1 with autoscaling/v2beta2 k8s api from receiver/k8scluster --- receiver/k8sclusterreceiver/watcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index f8d326b45097..40f6e8da48e0 100644 --- a/receiver/k8sclusterreceiver/watcher.go +++ b/receiver/k8sclusterreceiver/watcher.go @@ -28,7 +28,7 @@ import ( "go.uber.org/atomic" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - "k8s.io/api/autoscaling/v2beta2" + v2beta2 "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -98,7 +98,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() { rw.setupInformers(&appsv1.StatefulSet{}, factory.Apps().V1().StatefulSets().Informer()) rw.setupInformers(&batchv1.Job{}, factory.Batch().V1().Jobs().Informer()) rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) - rw.setupInformers(&v2beta1.HorizontalPodAutoscaler{}, + rw.setupInformers(&v2beta2.HorizontalPodAutoscaler{}, factory.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer(), ) From f806633e2c9d1b270bdc4bf244172e6a15567638 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Fri, 28 Jan 2022 00:24:36 +0530 Subject: [PATCH 4/7] Otel-collector-contrib-7386 replacing autoscaling/v2beta1 with autoscaling/v2beta2 k8s api from receiver/k8scluster --- .../k8sclusterreceiver/internal/collection/hpa_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go index 10ef3501a357..f2b926d8e879 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go @@ -19,7 +19,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" "github.com/stretchr/testify/require" - "k8s.io/api/autoscaling/v2beta2" + v2beta2 "k8s.io/api/autoscaling/v2beta2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -57,20 +57,20 @@ func TestHPAMetrics(t *testing.T) { metricspb.MetricDescriptor_GAUGE_INT64, 7) } -func newHPA(id string) *v2beta1.HorizontalPodAutoscaler { +func newHPA(id string) *v2beta2.HorizontalPodAutoscaler { minReplicas := int32(2) - return &v2beta1.HorizontalPodAutoscaler{ + return &v2beta2.HorizontalPodAutoscaler{ ObjectMeta: v1.ObjectMeta{ Name: "test-hpa-" + id, Namespace: "test-namespace", UID: types.UID("test-hpa-" + id + "-uid"), ClusterName: "test-cluster", }, - Status: v2beta1.HorizontalPodAutoscalerStatus{ + Status: v2beta2.HorizontalPodAutoscalerStatus{ CurrentReplicas: 5, DesiredReplicas: 7, }, - Spec: v2beta1.HorizontalPodAutoscalerSpec{ + Spec: v2beta2.HorizontalPodAutoscalerSpec{ MinReplicas: &minReplicas, MaxReplicas: 10, }, From 929fd32701ba67d394bc874ec7745ce091da23f8 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Mon, 7 Feb 2022 00:24:22 +0530 Subject: [PATCH 5/7] Otel-collector-contrib-7386 overcome redundant alias for k8s.io/api/autoscaling/v2beta2 --- .../internal/collection/collector.go | 6 +++--- receiver/k8sclusterreceiver/internal/collection/hpa.go | 8 ++++---- .../k8sclusterreceiver/internal/collection/hpa_test.go | 10 +++++----- receiver/k8sclusterreceiver/watcher.go | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/receiver/k8sclusterreceiver/internal/collection/collector.go b/receiver/k8sclusterreceiver/internal/collection/collector.go index 8debcd5fc3f7..9c374f673ab3 100644 --- a/receiver/k8sclusterreceiver/internal/collection/collector.go +++ b/receiver/k8sclusterreceiver/internal/collection/collector.go @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/collector/model/pdata" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - v2beta2 "k8s.io/api/autoscaling/v2beta2" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -147,7 +147,7 @@ func (dc *DataCollector) SyncMetrics(obj interface{}) { rm = getMetricsForJob(o) case *batchv1.CronJob: rm = getMetricsForCronJob(o) - case *v2beta2.HorizontalPodAutoscaler: + case *autoscalingv2beta2.HorizontalPodAutoscaler: rm = getMetricsForHPA(o) case *quotav1.ClusterResourceQuota: rm = getMetricsForClusterResourceQuota(o) @@ -184,7 +184,7 @@ func (dc *DataCollector) SyncMetadata(obj interface{}) map[metadata.ResourceID]* km = getMetadataForJob(o) case *batchv1.CronJob: km = getMetadataForCronJob(o) - case *v2beta2.HorizontalPodAutoscaler: + case *autoscalingv2beta2.HorizontalPodAutoscaler: km = getMetadataForHPA(o) } diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa.go b/receiver/k8sclusterreceiver/internal/collection/hpa.go index 16a5cd903d2c..dd762fecea01 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa.go @@ -18,7 +18,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" - v2beta2 "k8s.io/api/autoscaling/v2beta2" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" metadata "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/utils" @@ -52,7 +52,7 @@ var hpaDesiredReplicasMetric = &metricspb.MetricDescriptor{ Type: metricspb.MetricDescriptor_GAUGE_INT64, } -func getMetricsForHPA(hpa *v2beta2.HorizontalPodAutoscaler) []*resourceMetrics { +func getMetricsForHPA(hpa *autoscalingv2beta2.HorizontalPodAutoscaler) []*resourceMetrics { metrics := []*metricspb.Metric{ { MetricDescriptor: hpaMaxReplicasMetric, @@ -88,7 +88,7 @@ func getMetricsForHPA(hpa *v2beta2.HorizontalPodAutoscaler) []*resourceMetrics { } } -func getResourceForHPA(hpa *v2beta2.HorizontalPodAutoscaler) *resourcepb.Resource { +func getResourceForHPA(hpa *autoscalingv2beta2.HorizontalPodAutoscaler) *resourcepb.Resource { return &resourcepb.Resource{ Type: k8sType, Labels: map[string]string{ @@ -100,7 +100,7 @@ func getResourceForHPA(hpa *v2beta2.HorizontalPodAutoscaler) *resourcepb.Resourc } } -func getMetadataForHPA(hpa *v2beta2.HorizontalPodAutoscaler) map[metadata.ResourceID]*KubernetesMetadata { +func getMetadataForHPA(hpa *autoscalingv2beta2.HorizontalPodAutoscaler) map[metadata.ResourceID]*KubernetesMetadata { return map[metadata.ResourceID]*KubernetesMetadata{ metadata.ResourceID(hpa.UID): getGenericMetadata(&hpa.ObjectMeta, "HPA"), } diff --git a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go index f2b926d8e879..1d0f95a8ca48 100644 --- a/receiver/k8sclusterreceiver/internal/collection/hpa_test.go +++ b/receiver/k8sclusterreceiver/internal/collection/hpa_test.go @@ -19,7 +19,7 @@ import ( metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" "github.com/stretchr/testify/require" - v2beta2 "k8s.io/api/autoscaling/v2beta2" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -57,20 +57,20 @@ func TestHPAMetrics(t *testing.T) { metricspb.MetricDescriptor_GAUGE_INT64, 7) } -func newHPA(id string) *v2beta2.HorizontalPodAutoscaler { +func newHPA(id string) *autoscalingv2beta2.HorizontalPodAutoscaler { minReplicas := int32(2) - return &v2beta2.HorizontalPodAutoscaler{ + return &autoscalingv2beta2.HorizontalPodAutoscaler{ ObjectMeta: v1.ObjectMeta{ Name: "test-hpa-" + id, Namespace: "test-namespace", UID: types.UID("test-hpa-" + id + "-uid"), ClusterName: "test-cluster", }, - Status: v2beta2.HorizontalPodAutoscalerStatus{ + Status: autoscalingv2beta2.HorizontalPodAutoscalerStatus{ CurrentReplicas: 5, DesiredReplicas: 7, }, - Spec: v2beta2.HorizontalPodAutoscalerSpec{ + Spec: autoscalingv2beta2.HorizontalPodAutoscalerSpec{ MinReplicas: &minReplicas, MaxReplicas: 10, }, diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index 40f6e8da48e0..c5e97ece38fd 100644 --- a/receiver/k8sclusterreceiver/watcher.go +++ b/receiver/k8sclusterreceiver/watcher.go @@ -28,7 +28,7 @@ import ( "go.uber.org/atomic" "go.uber.org/zap" appsv1 "k8s.io/api/apps/v1" - v2beta2 "k8s.io/api/autoscaling/v2beta2" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -98,7 +98,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() { rw.setupInformers(&appsv1.StatefulSet{}, factory.Apps().V1().StatefulSets().Informer()) rw.setupInformers(&batchv1.Job{}, factory.Batch().V1().Jobs().Informer()) rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) - rw.setupInformers(&v2beta2.HorizontalPodAutoscaler{}, + rw.setupInformers(&autoscalingv2beta2.HorizontalPodAutoscaler{}, factory.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer(), ) From 88f91ba81d6bf17c30ff3019dde3a653e9fa5e51 Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Mon, 7 Feb 2022 21:08:07 +0530 Subject: [PATCH 6/7] Otel-collector-contrib-7386 Matching k8s Object for Autoscaling Api --- receiver/k8sclusterreceiver/watcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index c5e97ece38fd..79d9c943bd25 100644 --- a/receiver/k8sclusterreceiver/watcher.go +++ b/receiver/k8sclusterreceiver/watcher.go @@ -99,7 +99,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() { rw.setupInformers(&batchv1.Job{}, factory.Batch().V1().Jobs().Informer()) rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) rw.setupInformers(&autoscalingv2beta2.HorizontalPodAutoscaler{}, - factory.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer(), + factory.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer(), ) if rw.osQuotaClient != nil { From 7009b0a59348cda0a1285b1cd990224285ed9aef Mon Sep 17 00:00:00 2001 From: Shree Prakash Date: Tue, 8 Feb 2022 00:13:51 +0530 Subject: [PATCH 7/7] Otel-collector-contrib-7386 Matching k8s Object for Batch Api --- receiver/k8sclusterreceiver/watcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index 79d9c943bd25..b1c7cb89c6db 100644 --- a/receiver/k8sclusterreceiver/watcher.go +++ b/receiver/k8sclusterreceiver/watcher.go @@ -97,7 +97,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() { rw.setupInformers(&appsv1.ReplicaSet{}, factory.Apps().V1().ReplicaSets().Informer()) rw.setupInformers(&appsv1.StatefulSet{}, factory.Apps().V1().StatefulSets().Informer()) rw.setupInformers(&batchv1.Job{}, factory.Batch().V1().Jobs().Informer()) - rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1beta1().CronJobs().Informer()) + rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1().CronJobs().Informer()) rw.setupInformers(&autoscalingv2beta2.HorizontalPodAutoscaler{}, factory.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer(), )