Skip to content

Rewrite BucketReconciler to new standards#412

Merged
hiddeco merged 4 commits intoreconcilers-devfrom
bucket-reconciler
Aug 11, 2021
Merged

Rewrite BucketReconciler to new standards#412
hiddeco merged 4 commits intoreconcilers-devfrom
bucket-reconciler

Conversation

@hiddeco
Copy link
Copy Markdown
Member

@hiddeco hiddeco commented Jul 31, 2021

Supersedes #361

This PR rewrites the BucketReconciler to new standards, while
implementing the newly introduced Condition types, and trying to
adhere better to Kubernetes API conventions.

More specifically it introduces:

  • Implementation of more explicit Condition types to highlight
    abnormalities.
  • Extensive usage of the conditions subpackage from runtime.
  • Better and more conflict-resilient (status)patching of reconciled
    objects using the patch subpackage from runtime.
  • Proper implementation of kstatus' Reconciling and Stalled
    conditions.
  • Refactor of reconciler logic, including more efficient detection of
    changes to bucket objects by making use of the etag data available,
    and downloading of object files in parallel with a limited number of
    workers (4).
  • Integration tests that solely rely on testenv and do not
    use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

⚠️ target branch of the PR is a newly-introduced (protected) development branch.

@hiddeco hiddeco force-pushed the bucket-reconciler branch from ca456d3 to cd886e3 Compare July 31, 2021 14:42
@hiddeco hiddeco changed the title Rewrite BucketReconcilers to new standards Rewrite BucketReconciler to new standards Jul 31, 2021
@hiddeco hiddeco force-pushed the bucket-reconciler branch from cd886e3 to 4b82782 Compare August 3, 2021 12:50
@hiddeco hiddeco force-pushed the bucket-reconciler branch 3 times, most recently from cb7b730 to 3123992 Compare August 6, 2021 21:50
Comment thread api/v1beta1/bucket_types.go Outdated
Comment thread api/v1beta1/bucket_types.go Outdated
Comment thread controllers/bucket_controller.go Outdated
}, timeout).Should(BeTrue())
}

func TestBucketReconciler_reconcileStorage(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reconcileStorage() implementations for bucket and gitrepository reconcilers seem to be exactly the same. Should we have a common function with this one test? Currently there's no test for reconcileStorage in gitrepository reconciler.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had noticed this too, but not taken the time yet to think about how I wanted to factor it out. The same goes for garbageCollect by the way.

Comment thread controllers/bucket_controller_test.go
@hiddeco hiddeco force-pushed the bucket-reconciler branch 5 times, most recently from 8bc86ba to 4338305 Compare August 9, 2021 12:11
Comment thread controllers/gitrepository_controller.go
@hiddeco hiddeco force-pushed the bucket-reconciler branch from 4338305 to 0d2ae53 Compare August 9, 2021 13:59
@hiddeco hiddeco force-pushed the bucket-reconciler branch 2 times, most recently from 75f555c to 20bf5da Compare August 10, 2021 09:12
Comment thread controllers/bucket_controller.go Outdated
Comment thread controllers/bucket_controller_test.go
@hiddeco hiddeco force-pushed the bucket-reconciler branch 2 times, most recently from 0016698 to 8e2fdec Compare August 10, 2021 19:22
hiddeco and others added 3 commits August 10, 2021 22:11
This commit rewrites the `BucketReconciler` to new standards, while
implementing the newly introduced Condition types, and trying to
adhere better to Kubernetes API conventions.

More specifically it introduces:

- Implementation of more explicit Condition types to highlight
  abnormalities.
- Extensive usage of the `conditions` subpackage from `runtime`.
- Better and more conflict-resilient (status)patching of reconciled
  objects using the `patch` subpackage from runtime.
- Proper implementation of kstatus' `Reconciling` and `Stalled`
  conditions.
- Refactor of reconciler logic, including more efficient detection of
  changes to bucket objects by making use of the etag data available,
  and downloading of object files in parallel with a limited number of
  workers (4).
- Integration tests that solely rely on `testenv` and do not
  use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit consolidates the `DownloadFailed` and `CheckoutFailed`
Condition types into a new more generic `FetchFailed` type to simplify
the API and observations by consumers.

Signed-off-by: Hidde Beydals <hello@hidde.co>
Add `BucketReconciler.reconcileArtifact` tests based on
`GitRepositoryReconciler.reconcileArtifact` test cases.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
@hiddeco hiddeco force-pushed the bucket-reconciler branch from 8e2fdec to 3f2fcf3 Compare August 10, 2021 20:15
@hiddeco hiddeco marked this pull request as ready for review August 10, 2021 20:16
@hiddeco hiddeco requested a review from stefanprodan August 10, 2021 20:16
Copy link
Copy Markdown
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @hiddeco

This wraps the errors which are returned instead of logging them, as
the returned error is logged at the end of the reconcile run.

Signed-off-by: Hidde Beydals <hello@hidde.co>
@hiddeco hiddeco force-pushed the bucket-reconciler branch from 3f2fcf3 to 29f207d Compare August 11, 2021 07:35
@hiddeco hiddeco merged commit 19d7f83 into reconcilers-dev Aug 11, 2021
@hiddeco hiddeco deleted the bucket-reconciler branch August 11, 2021 07:52
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.

5 participants