-
Notifications
You must be signed in to change notification settings - Fork 14
Bucketaccess controller initial implementation #170
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
base: main
Are you sure you want to change the base?
Conversation
|
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for container-object-storage-interface ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BlaineEXE The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
e4e0aaf to
c1389c2
Compare
c1389c2 to
f06267c
Compare
192c36f to
0b5aa0f
Compare
0b5aa0f to
5c82de1
Compare
|
|
||
| func (r *BucketAccessReconciler) reconcile( | ||
| ctx context.Context, logger logr.Logger, access *cosiapi.BucketAccess, | ||
| ) (retryErrorType, error) { |
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.
One cool thing that I've learned recently is error tagging, e.g.:
https://github.com/siderolabs/gen/blob/main/xerrors/xerrors.go
We can use something like this here to return xerrors.Tag[Retryable](err) and then do xerrors.Is[Retryable]. Or we can do a custom wrapper that we can then check using stdlib errors.Is.
I'm not a fan of multiple return values here.
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.
I have a few parallel thoughts:
Overall I do think the suggestion and pattern would be a good one for us here. But, considering the other thoughts below, I think we can make our own error type/tag with very little boilerplate and Golang's errors.Is() without adding unnecessary complexity/dependencies. I don't think we need arbitrary tagging when there is only one case/tag we care about.
From a practical lens, I'd prefer to handle this in a follow-up PR because this pattern is already in place in the existing controllers that are merged. If we choose this pattern, I'd like to make sure all controllers are consistent.
As a final thought, I think I'd prefer not to pull in this particular dependency unless it becomes more broadly useful. The https://github.com/siderolabs/gen repo appears to basically be a large util library which we won't use most of, and I'm not much of a fan.
As for why this pattern exists: Originally, I was trying to return an error with reconcile.TerminalError(err) from the helpers, but there is a case where we need to convert the terminal error to a non-terminal error here:
container-object-storage-interface/controller/internal/reconciler/bucketclaim.go
Lines 70 to 80 in d587b32
| if updErr := r.Status().Update(ctx, claim); updErr != nil { | |
| logger.Error(err, "failed to update BucketClaim status after reconcile error", "updateError", updErr) | |
| // If status update fails, we must retry the error regardless of the reconcile return. | |
| // The reconcile needs to run again to make sure the status is eventually be updated. | |
| return reconcile.Result{}, err | |
| } | |
| if !retryError { | |
| return reconcile.Result{}, reconcile.TerminalError(err) | |
| } | |
| return reconcile.Result{}, 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.
We can track and discuss this with #174
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.
| } | ||
|
|
||
| // contains returns true if the given `list` contains the item `key`. | ||
| func contains[T comparable](list []T, key T) bool { |
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.
Use slices.Contains.
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.
Thanks! Done, and some future cleanup also: #176
| // ctrl.SetLogger(zap.New(zap.UseDevMode(true))) | ||
| // logger := ctrl.Log.WithName("predicate") | ||
| logger := logr.Discard() // comment this and uncomment above to locally test log messages |
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.
Can we use testr.New here?
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.
I think I'd prefer this to be a follow-up item because it brings up some philosophy questions about whether we want regular runtime logs to be printed during tests.
IMO, I think having runtime logs print during tests is helpful for debugging and manually ensuring logs are output when expected, but I deliberately avoided this in the unit tests so far because I know there are other preferences as well.
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.
We can track and discuss this with #175
5c82de1 to
c06e58d
Compare
Add initial implementation for BucketAccess reconciliation based on v1alpha2 KEP. This initial implementation covers only the first section of Controller reconciliation for a new BucketAccess. Coverage ends at the point where reconciliation is handed off to the Sidecar. Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
c06e58d to
c7d6ee1
Compare
Add initial implementation for BucketAccess reconciliation based on
v1alpha2 KEP. This initial implementation covers only the first section
of Controller reconciliation for a new BucketAccess. Coverage ends at the
point where reconciliation is handed off to the Sidecar.