Skip to content

Commit

Permalink
Fix bug in how we perform lifecycle config checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nolancon committed Jun 20, 2024
1 parent c88cd02 commit 54eee21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions internal/controller/bucket/bucket_backends.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func (b *bucketBackends) countBucketsAvailableOnBackends(bucket *v1alpha1.Bucket

// isLifecycleConfigAvailableOnBackends checks the backends listed in Spec.Providers against
// bucketBackends to ensure lifecycle configurations are considered Available on all desired backends.
func (b *bucketBackends) isLifecycleConfigAvailableOnBackends(bucket *v1alpha1.Bucket, c map[string]backendstore.S3Client) bool {
for _, backendName := range bucket.Spec.Providers {
func (b *bucketBackends) isLifecycleConfigAvailableOnBackends(bucket *v1alpha1.Bucket, providerNames []string, c map[string]backendstore.S3Client) bool {
for _, backendName := range providerNames {
if _, ok := c[backendName]; !ok {
// This backend does not exist in the list of available backends.
// The backend may be offline, so it is skipped.
Expand All @@ -170,8 +170,8 @@ func (b *bucketBackends) isLifecycleConfigAvailableOnBackends(bucket *v1alpha1.B

// isLifecycleConfigRemovedFromBackends checks the backends listed in Spec.Providers against
// bucketBackends to ensure lifecycle configurations are removed from all desired backends.
func (b *bucketBackends) isLifecycleConfigRemovedFromBackends(bucket *v1alpha1.Bucket, c map[string]backendstore.S3Client) bool {
for _, backendName := range bucket.Spec.Providers {
func (b *bucketBackends) isLifecycleConfigRemovedFromBackends(bucket *v1alpha1.Bucket, providerNames []string, c map[string]backendstore.S3Client) bool {
for _, backendName := range providerNames {
if _, ok := c[backendName]; !ok {
// This backend does not exist in the list of available backends.
// The backend may be offline, so it is skipped.
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/bucket/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ func isPauseRequired(bucket *v1alpha1.Bucket, providerNames []string, minReplica

// If lifecycle config is enabled and is specified in the spec, we should only pause once
// the lifecycle config is available on all backends.
if !bucket.Spec.LifecycleConfigurationDisabled && bucket.Spec.ForProvider.LifecycleConfiguration != nil && !bb.isLifecycleConfigAvailableOnBackends(bucket, c) {
if !bucket.Spec.LifecycleConfigurationDisabled && bucket.Spec.ForProvider.LifecycleConfiguration != nil && !bb.isLifecycleConfigAvailableOnBackends(bucket, providerNames, c) {
return false
}

// If lifecycle config is disabled, we should only pause once the lifecycle config is
// removed from all backends.
if bucket.Spec.LifecycleConfigurationDisabled && !bb.isLifecycleConfigRemovedFromBackends(bucket, c) {
if bucket.Spec.LifecycleConfigurationDisabled && !bb.isLifecycleConfigRemovedFromBackends(bucket, providerNames, c) {
return false
}

Expand Down

0 comments on commit 54eee21

Please sign in to comment.