Refactor Subresource Controllers#386
Draft
nolancon wants to merge 3 commits into
Draft
Conversation
d18da45 to
7fca301
Compare
Contributor
There was a problem hiding this comment.
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.goproviding shared Observe/Handle orchestration for subresources. - Refactors Lifecycle, Versioning, ObjectLock, SSE, Policy, and ACL subresource clients to embed
BaseSubresourceClientand implement theSubresourceinterface. - Updates unit tests to call the new exported
ObserveBackendmethods.
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
I have:
make ready-for-reviewto ensure this PR is ready for review.make ceph-chainsawto 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. Seedocs/TESTING.mdfor information on how to run tests against a Ceph cluster.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested