diff --git a/receiver/k8sclusterreceiver/internal/collection/collector.go b/receiver/k8sclusterreceiver/internal/collection/collector.go index 6039aa944415..9c374f673ab3 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" + autoscalingv2beta2 "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,9 +145,9 @@ 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: + case *autoscalingv2beta2.HorizontalPodAutoscaler: rm = getMetricsForHPA(o) case *quotav1.ClusterResourceQuota: rm = getMetricsForClusterResourceQuota(o) @@ -183,9 +182,9 @@ 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: + case *autoscalingv2beta2.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..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" - "k8s.io/api/autoscaling/v2beta1" + 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 *v2beta1.HorizontalPodAutoscaler) []*resourceMetrics { +func getMetricsForHPA(hpa *autoscalingv2beta2.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 *autoscalingv2beta2.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 *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 65e7c8f02679..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" - "k8s.io/api/autoscaling/v2beta1" + 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) *v2beta1.HorizontalPodAutoscaler { +func newHPA(id string) *autoscalingv2beta2.HorizontalPodAutoscaler { minReplicas := int32(2) - return &v2beta1.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: v2beta1.HorizontalPodAutoscalerStatus{ + Status: autoscalingv2beta2.HorizontalPodAutoscalerStatus{ CurrentReplicas: 5, DesiredReplicas: 7, }, - Spec: v2beta1.HorizontalPodAutoscalerSpec{ + Spec: autoscalingv2beta2.HorizontalPodAutoscalerSpec{ MinReplicas: &minReplicas, MaxReplicas: 10, }, diff --git a/receiver/k8sclusterreceiver/watcher.go b/receiver/k8sclusterreceiver/watcher.go index 0578310b81fd..b1c7cb89c6db 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" + autoscalingv2beta2 "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,9 +97,9 @@ 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(&v2beta1.HorizontalPodAutoscaler{}, - factory.Autoscaling().V2beta1().HorizontalPodAutoscalers().Informer(), + rw.setupInformers(&batchv1.CronJob{}, factory.Batch().V1().CronJobs().Informer()) + rw.setupInformers(&autoscalingv2beta2.HorizontalPodAutoscaler{}, + factory.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer(), ) if rw.osQuotaClient != nil {