Skip to content

Rewrite BucketReconciler to new standards #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 11, 2021
Merged

Conversation

hiddeco
Copy link
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
}, timeout).Should(BeTrue())
}

func TestBucketReconciler_reconcileStorage(t *testing.T) {
Copy link
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
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.

@hiddeco hiddeco force-pushed the bucket-reconciler branch 5 times, most recently from 8bc86ba to 4338305 Compare August 9, 2021 12:11
@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
@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 <[email protected]>
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 <[email protected]>
Add `BucketReconciler.reconcileArtifact` tests based on
`GitRepositoryReconciler.reconcileArtifact` test cases.

Signed-off-by: Sunny <[email protected]>
@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
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 <[email protected]>
@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