-
Notifications
You must be signed in to change notification settings - Fork 125
Refactor status collector architecture with structured errors #2016
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 #2016 +/- ##
==========================================
+ Coverage 48.12% 48.31% +0.19%
==========================================
Files 233 238 +5
Lines 29229 29952 +723
==========================================
+ Hits 14066 14472 +406
- Misses 14131 14380 +249
- Partials 1032 1100 +68 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Daniele Martinoli <[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.
In general I think this is a very nice refactor, one question about concurrent access inline
Signed-off-by: Daniele Martinoli <[email protected]>
- Removed the `Idle` phase from `SyncPhase` and updated related logic to ensure only `Syncing`, `Complete`, and `Failed` phases are used. - Enhanced the `ShouldSync` method to avoid syncing when the requeue timeout did not elapse. - Avoid updating sync status at all if sync is not needed (it would cause a new reconciliation) Signed-off-by: Daniele Martinoli <[email protected]>
@jhrozek @yrobla I reviewed the initial implementation again to:
The above changes prevent continuous reconciliation loops in case of failures, properly store incremental attempt counter in the sync status and respect the scheduled retries. Hopefully, the E2E tests will confirm that everything is fine |
Signed-off-by: Daniele Martinoli <[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.
awesome work @dmartinol
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.
Pull Request Overview
This PR refactors the status collector architecture by splitting the monolithic Collector
interface into domain-specific components and introducing structured error handling to improve separation of concerns and error propagation.
Key changes:
- Replaced monolithic
Collector
interface withSyncStatusCollector
,APIStatusCollector
, andStatusManager
interfaces - Introduced structured
Error
type to transport condition and phase information from low-level methods to the controller - Removed the
Idle
sync phase from the API and CRDs as it's no longer needed
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
cmd/thv-operator/controllers/mcpregistry_controller.go | Updated to use new status manager interfaces and handle structured errors from sync operations |
cmd/thv-operator/pkg/mcpregistrystatus/types.go | Refactored collector interfaces and added structured Error type |
cmd/thv-operator/pkg/mcpregistrystatus/collector.go | Implemented new interface structure with domain-specific collectors |
cmd/thv-operator/pkg/sync/manager.go | Refactored to return structured errors instead of using status collectors directly |
cmd/thv-operator/pkg/registryapi/manager.go | Updated to return structured errors instead of accepting status collectors |
cmd/thv-operator/api/v1alpha1/mcpregistry_types.go | Removed Idle sync phase from API definitions |
deploy/charts/operator-crds/crds/toolhive.stacklok.dev_mcpregistries.yaml | Updated CRD to remove Idle sync phase |
Comments suppressed due to low confidence (1)
cmd/thv-operator/pkg/sync/manager.go:1
- The variable name
DefaultControllerRetryAfter
is defined in the controller package but used here in the sync package. This creates a naming inconsistency and potential confusion. Consider using a package-local variable likeDefaultSyncRequeueAfter
which is already defined in this file.
package sync
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Fixes #2004
Collector
interface withSyncStatusCollector
andAPIStatusCollector
to pass only the needed one to the processing methodsError
type to transport condition and phase information to the root, instead of a generic errorThis change is needed to solve #1749 for error paths: some more changes may needed to fix the e2e tests.