Skip to content

Commit

Permalink
Otel-collector-contrib-7386 removing batch/v1beta1 and autoscaling/v2…
Browse files Browse the repository at this point in the history
…beta1 k8s api from receiver/k8scluster
  • Loading branch information
shree007 authored and hero committed Jan 27, 2022
1 parent 6bd4840 commit c236599
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
7 changes: 3 additions & 4 deletions receiver/k8sclusterreceiver/internal/collection/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions receiver/k8sclusterreceiver/internal/collection/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand All @@ -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{
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions receiver/k8sclusterreceiver/internal/collection/cronjobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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{{}, {}},
},
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/k8sclusterreceiver/internal/collection/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 2 additions & 3 deletions receiver/k8sclusterreceiver/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
)
Expand Down

0 comments on commit c236599

Please sign in to comment.