Skip to content

Commit

Permalink
feat: getting the error from status field for HPA analyzer (#1164)
Browse files Browse the repository at this point in the history
* getting the error from status field for hpa analyzer

Signed-off-by: naveenthangaraj03 <[email protected]>

* Signed-off

Signed-off-by: naveenthangaraj03 <[email protected]>

* Updated the hpaAnalyzer_test.go

Signed-off-by: naveenthangaraj03 <[email protected]>

* Updated hpa_test.go

Signed-off-by: naveenthangaraj03 <[email protected]>

* Updated the hpa

Signed-off-by: naveenthangaraj03 <[email protected]>

* Updated the Conflicts

Signed-off-by: naveenthangaraj03 <[email protected]>

* Resolved all the conflicts

Signed-off-by: naveenthangaraj03 <[email protected]>

* Updated the test case

Signed-off-by: naveenthangaraj03 <[email protected]>

---------

Signed-off-by: naveenthangaraj03 <[email protected]>
Co-authored-by: Alex Jones <[email protected]>
Co-authored-by: Matthis <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent 8949f5b commit a068310
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 32 deletions.
14 changes: 13 additions & 1 deletion pkg/analyzer/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (HpaAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
"analyzer_name": kind,
})

list, err := a.Client.GetClient().AutoscalingV1().HorizontalPodAutoscalers(a.Namespace).List(a.Context, metav1.ListOptions{LabelSelector: a.LabelSelector})
list, err := a.Client.GetClient().AutoscalingV2().HorizontalPodAutoscalers(a.Namespace).List(a.Context, metav1.ListOptions{LabelSelector: a.LabelSelector})
if err != nil {
return nil, err
}
Expand All @@ -53,6 +53,18 @@ func (HpaAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
for _, hpa := range list.Items {
var failures []common.Failure


//check the error from status field
conditions := hpa.Status.Conditions
for _, condition := range conditions {
if condition.Status != "True" {
failures = append(failures, common.Failure{
Text: condition.Message,
Sensitive: []common.Sensitive{},
})
}
}

// check ScaleTargetRef exist
scaleTargetRef := hpa.Spec.ScaleTargetRef
var podInfo PodInfo
Expand Down
Loading

0 comments on commit a068310

Please sign in to comment.