Skip to content

Why ignore objects without pods in the dangling-hpa check? #932

@mboutet

Description

@mboutet

Originally posted as a discussion in https://github.com/stackrox/kube-linter/discussions/931but but reopening as an issue as it appears that discussions rarely get answered.


for _, obj := range lintCtx.Objects() {
_, hasPods := extract.PodTemplateSpec(obj.K8sObject)
if !hasPods {
continue

I have a HPA targeting a KafkaNodePool resource but because of that condition in the code, it doesn't go further and it flags my HPA as being dangling.

Why is it needed to check if the potential target object has pods? Why is it not sufficient for this check to only make sure that the scaleTargetRef exists (as it's already doing later in the loop as shown below)?

k8sObj := obj.K8sObject
gvk := k8sObj.GetObjectKind().GroupVersionKind()
if target.Name == obj.GetK8sObjectName().Name && target.Kind == gvk.Kind && target.APIVersion == gvk.Group+"/"+gvk.Version {
// Found!
return nil
}

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions