Skip to content

Conversation

dmartinol
Copy link
Collaborator

Fixes #2004

  • Split the monolithic Collector interface with SyncStatusCollector and APIStatusCollector to pass only the needed one to the processing methods
  • Use an Error type to transport condition and phase information to the root, instead of a generic error
  • This way, the low-level methods do not need the collectors because they raise the error that carries the desired information

This change is needed to solve #1749 for error paths: some more changes may needed to fix the e2e tests.

@dmartinol dmartinol requested a review from jhrozek September 25, 2025 16:58
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 26.05364% with 193 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.89%. Comparing base (84041cc) to head (2e52dee).

Files with missing lines Patch % Lines
...ator/pkg/mcpregistrystatus/mocks/mock_collector.go 0.00% 77 Missing ⚠️
...thv-operator/controllers/mcpregistry_controller.go 0.00% 62 Missing ⚠️
cmd/thv-operator/pkg/sync/manager.go 23.80% 32 Missing ⚠️
cmd/thv-operator/pkg/registryapi/manager.go 0.00% 17 Missing ⚠️
...thv-operator/pkg/registryapi/mocks/mock_manager.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2016      +/-   ##
==========================================
- Coverage   47.96%   47.89%   -0.07%     
==========================================
  Files         233      235       +2     
  Lines       29172    29226      +54     
==========================================
+ Hits        13991    13997       +6     
- Misses      14148    14197      +49     
+ Partials     1033     1032       -1     

☔ 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.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Copy link
Contributor

@jhrozek jhrozek left a 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

Type: mcpv1alpha1.ConditionAPIReady,
// SetCondition sets a general condition with the specified type, reason, message, and status
func (s *StatusCollector) SetCondition(conditionType, reason, message string, status metav1.ConditionStatus) {
s.conditions[conditionType] = metav1.Condition{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly cause by your patch but since we have multiple methods writing into s.conditions do you think we should use a SyncMap or similar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, controller-runtime ensures single-threaded execution per resource instance. Within a single reconciliation, all method calls are sequential, not concurrent. So, Im not sure we need any synchronized data access, given that each reconciliation creates a new StatusManager with its own map of conditions.
Let me know what you think about this (yes, I asked CC before replying 😉 )

// API reconciliation successful - check readiness and set appropriate status
isReady := r.registryAPIManager.IsAPIReady(ctx, mcpRegistry)
if isReady {
// TODO: Get actual service endpoint - for now, construct it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why wasn't it covered here, is it complex to retrieve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review the design of Collector interface
3 participants