mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-08-11 20:51:37 +00:00
feat: enhancement of deployment analyzer (#1406)
* Updated the deployment analyzer Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com> * Enhanced the deployment analyzer Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com> --------- Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com> Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
parent
6a81d2c140
commit
61b60d5768
@ -54,11 +54,12 @@ func (d DeploymentAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
|
|||||||
|
|
||||||
for _, deployment := range deployments.Items {
|
for _, deployment := range deployments.Items {
|
||||||
var failures []common.Failure
|
var failures []common.Failure
|
||||||
if *deployment.Spec.Replicas != deployment.Status.Replicas {
|
if *deployment.Spec.Replicas != deployment.Status.ReadyReplicas {
|
||||||
|
if deployment.Status.Replicas > *deployment.Spec.Replicas {
|
||||||
doc := apiDoc.GetApiDocV2("spec.replicas")
|
doc := apiDoc.GetApiDocV2("spec.replicas")
|
||||||
|
|
||||||
failures = append(failures, common.Failure{
|
failures = append(failures, common.Failure{
|
||||||
Text: fmt.Sprintf("Deployment %s/%s has %d replicas but %d are available", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.Replicas),
|
Text: fmt.Sprintf("Deployment %s/%s has %d replicas in spec but %d replicas in status because status field is not updated yet after scaling and %d replicas are available with status running", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.Replicas, deployment.Status.ReadyReplicas),
|
||||||
KubernetesDoc: doc,
|
KubernetesDoc: doc,
|
||||||
Sensitive: []common.Sensitive{
|
Sensitive: []common.Sensitive{
|
||||||
{
|
{
|
||||||
@ -70,6 +71,24 @@ func (d DeploymentAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
|
|||||||
Masked: util.MaskString(deployment.Name),
|
Masked: util.MaskString(deployment.Name),
|
||||||
},
|
},
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
doc := apiDoc.GetApiDocV2("spec.replicas")
|
||||||
|
|
||||||
|
failures = append(failures, common.Failure{
|
||||||
|
Text: fmt.Sprintf("Deployment %s/%s has %d replicas but %d are available with status running", deployment.Namespace, deployment.Name, *deployment.Spec.Replicas, deployment.Status.ReadyReplicas),
|
||||||
|
KubernetesDoc: doc,
|
||||||
|
Sensitive: []common.Sensitive{
|
||||||
|
{
|
||||||
|
Unmasked: deployment.Namespace,
|
||||||
|
Masked: util.MaskString(deployment.Namespace),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Unmasked: deployment.Name,
|
||||||
|
Masked: util.MaskString(deployment.Name),
|
||||||
|
},
|
||||||
|
}})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
preAnalysis[fmt.Sprintf("%s/%s", deployment.Namespace, deployment.Name)] = common.PreAnalysis{
|
preAnalysis[fmt.Sprintf("%s/%s", deployment.Namespace, deployment.Name)] = common.PreAnalysis{
|
||||||
|
Loading…
Reference in New Issue
Block a user