Skip to content

Refactor Subresource Controllers#386

Draft
nolancon wants to merge 3 commits into
mainfrom
subresources-refactor
Draft

Refactor Subresource Controllers#386
nolancon wants to merge 3 commits into
mainfrom
subresources-refactor

Conversation

@nolancon
Copy link
Copy Markdown
Collaborator

Description of your changes

I have:

  • Run make ready-for-review to ensure this PR is ready for review.
  • Run make ceph-chainsaw to validate these changes against Ceph. This step is not always necessary. However, for changes related to S3 calls it is sensible to validate against an actual Ceph cluster. Localstack is used in our CI Chainsaw suite for convenience and there can be disparity in S3 behaviours between it and Ceph. See docs/TESTING.md for information on how to run tests against a Ceph cluster.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 bucket subresource controllers to share common Observe/Handle behavior via a new BaseSubresourceClient + Subresource interface, reducing duplicated concurrency/health-check/tracing logic across subresources.

Changes:

  • Introduces internal/controller/bucket/base_subresource.go providing shared Observe/Handle orchestration for subresources.
  • Refactors Lifecycle, Versioning, ObjectLock, SSE, Policy, and ACL subresource clients to embed BaseSubresourceClient and implement the Subresource interface.
  • Updates unit tests to call the new exported ObserveBackend methods.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/controller/bucket/base_subresource.go Adds shared subresource Observe/Handle implementation and the Subresource interface.
internal/controller/bucket/versioningconfiguration.go Refactors VersioningConfiguration client to use BaseSubresourceClient and implement Subresource.
internal/controller/bucket/versioningconfiguration_test.go Updates tests for renamed/exported ObserveBackend.
internal/controller/bucket/serversideencryptionconfiguration.go Refactors SSE client to use the shared base subresource logic.
internal/controller/bucket/serversideencryptionconfiguration_test.go Updates tests for renamed/exported ObserveBackend.
internal/controller/bucket/policy.go Refactors Policy client to use the shared base subresource logic.
internal/controller/bucket/policy_test.go Updates tests for renamed/exported ObserveBackend.
internal/controller/bucket/objectlockconfiguration.go Refactors ObjectLock client to use the shared base logic and adds conditional observation via SkipObservation.
internal/controller/bucket/objectlockconfiguration_test.go Updates tests for renamed/exported ObserveBackend.
internal/controller/bucket/lifecycleconfiguration.go Refactors Lifecycle client to use the shared base subresource logic.
internal/controller/bucket/lifecycleconfiguration_test.go Updates tests for renamed/exported ObserveBackend.
internal/controller/bucket/acl.go Refactors ACL client to use the shared base subresource logic and new ObserveBackend signature.
internal/controller/bucket/acl_test.go Updates ACL tests for ObserveBackend and adds require assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +90 to +94
for _, backendName := range backendNames {
beName := backendName
go func() {
if subresource.GetBackendStore().GetBackendHealthStatus(backendName) == apisv1alpha1.HealthStatusUnhealthy {
// If a backend is marked as unhealthy, we can ignore it for now by returning NoAction.
Comment on lines 116 to 120
case NeedsDeletion:
if err := p.delete(ctx, b, backendName); err != nil {
err = errors.Wrap(err, errHandlePolicy)

traces.SetAndRecordError(span, err)

return err
}
return p.delete(ctx, bucket, backendName)
case NeedsUpdate:
if err := p.createOrUpdate(ctx, b, backendName); err != nil {
err = errors.Wrap(err, errHandlePolicy)

traces.SetAndRecordError(span, err)

return err
}
return p.createOrUpdate(ctx, bucket, backendName)
}
Comment on lines +92 to 96
func (a *ACLClient) HandleObservation(ctx context.Context, observation ResourceStatus, bucket *v1alpha1.Bucket, backendName string, bb *bucketBackends) error {
switch observation {
case NoAction, Updated:
return nil
case NeedsUpdate, NeedsDeletion:
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.

2 participants