Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the k8scluster receiver is watching for hpa v2 #21497

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/fix-k8sclusterreceiver-hpav2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/k8scluster

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Make sure the k8scluster receiver is watching for v2 and v2beta2 HorizontalPodAutoscalers for Kubernetes 1.26

# One or more tracking issues related to the change
issues: [20480]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
31 changes: 16 additions & 15 deletions receiver/k8sclusterreceiver/internal/gvk/gvk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ import "k8s.io/apimachinery/pkg/runtime/schema"

// Kubernetes group version kinds
var (
Pod = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"}
Node = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Node"}
Namespace = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}
ReplicationController = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ReplicationController"}
ResourceQuota = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ResourceQuota"}
Service = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"}
DaemonSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "DaemonSet"}
Deployment = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
ReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"}
StatefulSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"}
Job = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}
CronJob = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "CronJob"}
CronJobBeta = schema.GroupVersionKind{Group: "batch", Version: "v1beta1", Kind: "CronJob"}
HorizontalPodAutoscaler = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}
ClusterResourceQuota = schema.GroupVersionKind{Group: "quota", Version: "v1", Kind: "ClusterResourceQuota"}
Pod = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Pod"}
Node = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Node"}
Namespace = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Namespace"}
ReplicationController = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ReplicationController"}
ResourceQuota = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ResourceQuota"}
Service = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"}
DaemonSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "DaemonSet"}
Deployment = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
ReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"}
StatefulSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "StatefulSet"}
Job = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "Job"}
CronJob = schema.GroupVersionKind{Group: "batch", Version: "v1", Kind: "CronJob"}
CronJobBeta = schema.GroupVersionKind{Group: "batch", Version: "v1beta1", Kind: "CronJob"}
HorizontalPodAutoscaler = schema.GroupVersionKind{Group: "autoscaling", Version: "v2", Kind: "HorizontalPodAutoscaler"}
HorizontalPodAutoscalerBeta = schema.GroupVersionKind{Group: "autoscaling", Version: "v2beta2", Kind: "HorizontalPodAutoscaler"}
ClusterResourceQuota = schema.GroupVersionKind{Group: "quota", Version: "v1", Kind: "ClusterResourceQuota"}
)
2 changes: 1 addition & 1 deletion receiver/k8sclusterreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func newFakeClientWithAllResources() *fake.Clientset {
{
GroupVersion: "autoscaling/v2beta2",
APIResources: []v1.APIResource{
gvkToAPIResource(gvk.HorizontalPodAutoscaler),
gvkToAPIResource(gvk.HorizontalPodAutoscalerBeta),
},
},
}
Expand Down
4 changes: 3 additions & 1 deletion receiver/k8sclusterreceiver/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (rw *resourceWatcher) prepareSharedInformerFactory() error {
"StatefulSet": {gvk.StatefulSet},
"Job": {gvk.Job},
"CronJob": {gvk.CronJob, gvk.CronJobBeta},
"HorizontalPodAutoscaler": {gvk.HorizontalPodAutoscaler},
"HorizontalPodAutoscaler": {gvk.HorizontalPodAutoscaler, gvk.HorizontalPodAutoscalerBeta},
}

for kind, gvks := range supportedKinds {
Expand Down Expand Up @@ -197,6 +197,8 @@ func (rw *resourceWatcher) setupInformerForKind(kind schema.GroupVersionKind, fa
case gvk.CronJobBeta:
rw.setupInformer(kind, factory.Batch().V1beta1().CronJobs().Informer())
case gvk.HorizontalPodAutoscaler:
rw.setupInformer(kind, factory.Autoscaling().V2().HorizontalPodAutoscalers().Informer())
case gvk.HorizontalPodAutoscalerBeta:
rw.setupInformer(kind, factory.Autoscaling().V2beta2().HorizontalPodAutoscalers().Informer())
default:
rw.logger.Error("Could not setup an informer for provided group version kind",
Expand Down
8 changes: 7 additions & 1 deletion receiver/k8sclusterreceiver/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,17 @@ func TestPrepareSharedInformerFactory(t *testing.T) {
},
},
{
GroupVersion: "autoscaling/v2beta2",
GroupVersion: "autoscaling/v2",
APIResources: []metav1.APIResource{
gvkToAPIResource(gvk.HorizontalPodAutoscaler),
},
},
{
GroupVersion: "autoscaling/v2beta2",
APIResources: []metav1.APIResource{
gvkToAPIResource(gvk.HorizontalPodAutoscalerBeta),
},
},
}
return client
}(),
Expand Down