Skip to content
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

First-start reconcilation loop #30

Closed
shanesveller opened this issue Feb 19, 2019 · 3 comments
Closed

First-start reconcilation loop #30

shanesveller opened this issue Feb 19, 2019 · 3 comments

Comments

@shanesveller
Copy link

Disclaimer: Code links are merely for my own reference and other less-familiar readers, and are by no means meant to imply that the maintainer does not know the contents of their own codebase. 😄

Environment

  • Bonny version: 0.2.3
  • Elixir & Erlang/OTP versions (elixir --version): (any supported)
  • Operating system: (any supported)

Current behavior

The current Bonny.Controller behaviour defines the add, modify and delete callbacks and includes these three events in the mix bonny.gen.controller templating.

Expected behavior

I would like to propose an additional callback of reconcile (or another representative terminology) that will, during the first boot cycle and again periodically on a configurable timer, examine existing CRDs within the operator's purview. Then it will ensure that any appropriate action has been taken based on their contents, i.e. that managed descendent resources exist with the desired content. With an eye for as much idempotency as possible, it should correct any configuration drift that may have happened while a Bonny-based operator was offline, misbehaving, etc.

This is a common practice in other operator codebases and frameworks, and would help enable the declarative, convergent behavior that we've come to appreciate from standard Kubernetes primitives.

Other notes

The current Bonny.Watcher implementation short-circuits the review of existing resources that match the watch request within the Bonny.Watcher.Impl module, which on the first request without a resource version:

Defaults to changes from the beginning of history

This feature probably also depends on #27 for clean access to the /status subresource to make it truly graceful to handle pre-existing CRDs which have already been realized.

Finally, I have half-formed ideas of trying this on my own project that may result in a PR here for discussion purposes, but I'm not yet using this library at work and will have difficulty committing the time soon.

@coryodaniel
Copy link
Owner

This sounds like a good option if the function is defined by a user, the Watcher can start a timer to call it periodically.

Re: the beginning of time, I was planning to bump a minor version when I migrate to k8s library. When doing this I was also going to change the default from beginning of time to the “current” revision stamp.

@shanesveller
Copy link
Author

Regarding the very last point, I'm not certain based on the phrasing, but I think it might be counter to the goal I was expressing with this issue. In short, when my operator starts up, I want an opportunity to examine all existing CRDs that my operator is interested in, ideally without firing an extra request to fetch this history. The very first request the library performs upon launch already includes the information I'm after, it's just discarded after the latest resource version is parsed rather than passed on anywhere else.

@coryodaniel
Copy link
Owner

coryodaniel commented Mar 6, 2019 via email

coryodaniel added a commit that referenced this issue Apr 11, 2019
* [Added] support for a `reconcile/1` callback.Added support for a
`reconcile/1` callback.
* [ADDED] `reconcile_every` config option to schedule how often to run
reconciliation
* [ADDED] `reconcile_batch_size` to set the size of the HTTP GET limit
when fetching batches of items to reconcile
* [FIXED] receiving `:DOWN` messages no longer crashes Watcher #20
* [FIXED] issue with partially received events #43

Closes #43
Closes #20
Closes #30
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

No branches or pull requests

2 participants