Skip to content

Comments

feat: enhancement of deployment analyzer#1406

Merged
AlexsJones merged 5 commits intok8sgpt-ai:mainfrom
naveenthangaraj03:deployment-analyzer
May 6, 2025
Merged

feat: enhancement of deployment analyzer#1406
AlexsJones merged 5 commits intok8sgpt-ai:mainfrom
naveenthangaraj03:deployment-analyzer

Conversation

@naveenthangaraj03
Copy link
Contributor

Closes #

📑 Description

ISSUE:

  • The deployment analyzer is not getting the real time error

RESOLVED:

  • Instead of checking status.replica field checking with status.readyreplica 
  • And also checking the status field when we scale down the replica 
root@iks-get-648n8:/tmp# ./k8sgpt analyze --filter=Deployment  --explain --no-cache
 100% |███████████████████████████████████████████████████████████████████████████████████████████████████| (7/7, 11 it/min)
AI Provider: openai

0: Deployment jenkins-2/myweb()
- Error: Deployment jenkins-2/myweb has 1 replicas in spec but 2 replicas in status because status field is not updated yet after scaling and 0 replicas are available with status running
Error: Deployment 'jenkins-2/myweb' has mismatched replicas in spec (1) and status (2), with 0 available replicas running.

Solution:
1. Check deployment scaling history.
2. Run `kubectl rollout status deployment myweb -n jenkins-2`.
3. Verify pod status with `kubectl get pods -n jenkins-2`.
4. If issue persists, try `kubectl rollout restart deployment myweb -n jenkins-2`.
1: Deployment jenkins/jenkins-operator()
- Error: Deployment jenkins/jenkins-operator has 1 replicas but 0 are available with status running
Error: The error indicates that the 'jenkins-operator' deployment in the 'jenkins' namespace has 1 replica, but none of them are running. This means the deployment is not available.

Solution:
1. Check pod status: `kubectl get pods -n jenkins`
2. Describe pod: `kubectl describe pod <pod_name> -n jenkins`
3. Check logs: `kubectl logs <pod_name> -n jenkins`
4. Scale deployment: `kubectl scale deployment jenkins-operator --replicas=1 -n jenkins`

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
@codecov
Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 48.57143% with 18 lines in your changes missing coverage. Please review.

Project coverage is 42.59%. Comparing base (173e4dc) to head (ee82200).
Report is 138 commits behind head on main.

Files with missing lines Patch % Lines
pkg/analyzer/deployment.go 48.57% 16 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1406      +/-   ##
==========================================
+ Coverage   34.76%   42.59%   +7.82%     
==========================================
  Files          94      106      +12     
  Lines        6342     7553    +1211     
==========================================
+ Hits         2205     3217    +1012     
- Misses       4046     4188     +142     
- Partials       91      148      +57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@naveenthangaraj03
Copy link
Contributor Author

@AlexsJones The status field will not update sometimes if we scale down the replicas so that's why i checked deployment.Status.Replicas > *deployment.Spec.Replicas if it's not need for our case just suggest me and i will remove that case.

But we need to check deployment.Status.ReadyReplicas instead of deployment.Status.Replicas

Comment down the changes you expect I will change according to that.

@naveenthangaraj03
Copy link
Contributor Author

Hi Alex, Just wanted to know about this PR, let me know if I want to update.

@AlexsJones AlexsJones merged commit 61b60d5 into k8sgpt-ai:main May 6, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from Proposed to Done in Backlog May 6, 2025
naveenthangaraj03 added a commit to naveenthangaraj03/k8sgpt that referenced this pull request Aug 13, 2025
* 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>
Signed-off-by: naveenthangaraj03 <tnaveen3402@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right on-hold

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants