Skip to content
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

AdviceReconciler #502

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

scothis
Copy link
Contributor

@scothis scothis commented Mar 27, 2024

A sketch of a potential method for defining advice for a SubReconciler as a SubReconciler. It can be composed manually into existing SubReconciler hierarchies. Other composition strategies could be explored in the future.

This does not address advice for ResourceReconciler, AggregateReconciler, or AdmissionWebhookAdapter.

Refs #500

Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis scothis marked this pull request as draft March 27, 2024 16:21
@scothis
Copy link
Contributor Author

scothis commented Mar 27, 2024

cc @squeedee

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 43.61702% with 53 lines in your changes are missing coverage. Please review.

Project coverage is 60.43%. Comparing base (a63803b) to head (daa0cac).
Report is 12 commits behind head on main.

Files Patch % Lines
reconcilers/advice.go 0.00% 44 Missing ⚠️
reconcilers/null.go 0.00% 4 Missing ⚠️
reconcilers/aggregate.go 83.33% 2 Missing and 1 partial ⚠️
reconcilers/resource.go 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #502      +/-   ##
==========================================
- Coverage   61.13%   60.43%   -0.70%     
==========================================
  Files          28       30       +2     
  Lines        2583     2669      +86     
==========================================
+ Hits         1579     1613      +34     
- Misses        917      967      +50     
- Partials       87       89       +2     

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

reconcilers/advice.go Outdated Show resolved Hide resolved
_ SubReconciler[client.Object] = (*NullReconciler[client.Object])(nil)
)

// NullReconciler does nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

[question]: Is this for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not just for testing. Since the Reconciler field is required, but Around can choose not to invoke a reconciler it's an easy way to define something that implements the interface, but does nothing.

Co-authored-by: Max Brauer <mamachanko@users.noreply.github.com>
Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis scothis mentioned this pull request Apr 4, 2024
@squeedee
Copy link
Collaborator

squeedee commented Apr 4, 2024

This is really great. I started at the Top level reconciler so it didn't occur to me that composable subreconcilers will work for everything else.. I guess a delegate with the same interface for the top level?

…hookAdapter

Signed-off-by: Scott Andrews <scott@andrews.me>
@yharish991
Copy link

@scothis I was trying AdviceReconciler and identified a small bug, line 312 in reconcilers/resource.go should be

r.AfterReconcile(ctx, req, result, nil)

Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis
Copy link
Contributor Author

scothis commented Apr 18, 2024

@scothis I was trying AdviceReconciler and identified a small bug, line 312 in reconcilers/resource.go should be

r.AfterReconcile(ctx, req, result, nil)

@yharish991 good catch, I refactored a bit to make sure this can't happen in the future.

@squeedee
Copy link
Collaborator

@scothis @yharish991 has been using this directly. We're finding this quite useful so far. Do you plan on moving it from "sketch" status? Personally. I think it's a good approach and will serve users well.

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.

None yet

4 participants