-
Notifications
You must be signed in to change notification settings - Fork 7
chore: return an error if the DRA provider has an empty domain set #189
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #189 +/- ##
==========================================
- Coverage 64.90% 64.84% -0.07%
==========================================
Files 78 78
Lines 4266 4275 +9
==========================================
+ Hits 2769 2772 +3
- Misses 1390 1395 +5
- Partials 107 108 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile OverviewGreptile SummaryAdded error handling to return clear error messages when the DRA provider finds no matching nodes with the required labels and annotations. The PR also refactored the retry loop and added defensive logging for empty block topology data. Key Changes:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant Server
participant Provider as DRA Provider
participant K8s as Kubernetes API
Client->>Server: Request Topology
Server->>Server: processRequestWithRetries(maxRetries=5)
loop Retry attempts (1-5)
Server->>Provider: GenerateTopologyConfig()
Provider->>K8s: GetNodes()
K8s-->>Provider: Return nodes
Provider->>Provider: Filter nodes by label and annotations
Provider->>Provider: Build domainMap
alt domainMap is empty
Provider-->>Server: Error: no matching nodes found
Server->>Server: Check if StatusInternalServerError
alt attempt < maxRetries
Server->>Server: Exponential backoff
else attempt == maxRetries
Server-->>Client: Return error
end
else domainMap has entries
Provider->>Provider: toGraph(domainMap)
Provider-->>Server: Return topology
Server-->>Client: Success response
end
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 1 comment
pkg/server/engine.go
Outdated
| attempt := 0 | ||
| for { | ||
| var code int | ||
| attempt++ | ||
| start := time.Now() | ||
|
|
||
| ret, err := f(tr) | ||
| if err != nil { | ||
| code = err.Code() | ||
| } else { | ||
| code = http.StatusOK | ||
| } | ||
| metrics.AddTopologyRequest(tr.Provider.Name, tr.Engine.Name, code, time.Since(start)) | ||
|
|
||
| if code != http.StatusInternalServerError || attempt == maxRetries { | ||
| if code != http.StatusInternalServerError || attempt >= maxRetries { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The refactored retry loop now makes 5 attempts instead of the original 6. Old code: for attempt := 0; attempt <= maxRetries made attempts 0-5 (6 total). New code: attempt++ then attempt >= maxRetries makes attempts 1-5 (5 total).
| attempt := 0 | |
| for { | |
| attempt++ | |
| var code int | |
| start := time.Now() | |
| ret, err := f(tr) | |
| if err != nil { | |
| code = err.Code() | |
| } else { | |
| code = http.StatusOK | |
| } | |
| metrics.AddTopologyRequest(tr.Provider.Name, tr.Engine.Name, code, time.Since(start)) | |
| if code != http.StatusInternalServerError || attempt > maxRetries { | |
| return ret, err | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
Signed-off-by: Dmitry Shmulevich <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
No description provided.