Skip to content

Conversation

@BlaineEXE
Copy link
Contributor

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.

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 29, 2025
@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for container-object-storage-interface ready!

Name Link
🔨 Latest commit c7d6ee1
🔍 Latest deploy log https://app.netlify.com/projects/container-object-storage-interface/deploys/690e39fd65e9730008176983
😎 Deploy Preview https://deploy-preview-170--container-object-storage-interface.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 29, 2025
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 29, 2025
@BlaineEXE BlaineEXE force-pushed the bucketaccess-controller branch from e4e0aaf to c1389c2 Compare October 29, 2025 16:51
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 29, 2025
@BlaineEXE BlaineEXE force-pushed the bucketaccess-controller branch from c1389c2 to f06267c Compare October 31, 2025 22:13
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 31, 2025
@BlaineEXE BlaineEXE force-pushed the bucketaccess-controller branch 3 times, most recently from 192c36f to 0b5aa0f Compare November 5, 2025 20:02
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 5, 2025
@BlaineEXE BlaineEXE force-pushed the bucketaccess-controller branch from 0b5aa0f to 5c82de1 Compare November 5, 2025 21:09
@BlaineEXE BlaineEXE marked this pull request as ready for review November 5, 2025 21:11
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 5, 2025
@BlaineEXE BlaineEXE mentioned this pull request Nov 6, 2025
30 tasks

func (r *BucketAccessReconciler) reconcile(
ctx context.Context, logger logr.Logger, access *cosiapi.BucketAccess,
) (retryErrorType, error) {
Copy link
Member

@shanduur shanduur Nov 7, 2025

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.

Copy link
Contributor Author

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:

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a prototype fix here: #177

If you like the prototype (I think it's a good balance), we can merge this, then I can finish the prototype to include the BAccess controller. Or we can merge the prototype first, and I can fix the retryError stuff here to match.

@shanduur LMK your thoughts

}

// contains returns true if the given `list` contains the item `key`.
func contains[T comparable](list []T, key T) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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

Comment on lines +35 to +37
// 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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

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>
@BlaineEXE BlaineEXE force-pushed the bucketaccess-controller branch from c06e58d to c7d6ee1 Compare November 7, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants