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

The One with the Plan #13

Closed
linki opened this issue Feb 15, 2017 · 7 comments
Closed

The One with the Plan #13

linki opened this issue Feb 15, 2017 · 7 comments
Milestone

Comments

@linki
Copy link
Member

linki commented Feb 15, 2017

Background

When developing mate we found out that one of the more difficult parts was calculating the diff from a current state to a desired state of dns records. In mate, this responsibility was part of each consumer implementation although many things could have been shared between consumers and it was difficult to test.

Glossary:

  • producer: source of desired dns records
  • consumer: adapter to the specific dns provider
  • controller: glue between producers and consumers

Proposal

We propose an intermediate object that's used to capture the transition that's needed to go from a current to a desired state of dns recors in a dns-provider-independent way. This object would then be used as input to the consumers and the logic is not part of each of them.

Hence, making the consumer implementations easier to write (less responsibilities) and allowing the intermediate object to be easier to test (less external dependencies). I would like to call this object Plan as it's a sort of execution plan.

A plan would be constructed from two input lists:

  • a desired list of records and a current list of records.

And it would return three lists as output:

  • a list of records to create
  • a list of records to update (including old and new records)
  • a list of records to delete

This plan object can be tested in isolation and many combinations and edge cases can easily be added to the test suite.

The plan would then be passed to a consumer object which would "just execute" the actions according to the dns provider. This also makes each consumer easier to test as one just needs to provide a Plan and see that the consumer runs the right actions against the dns provider. Any errors that may happen (e.g. because of records to delete that don't exist) can be considered errors and don't need to be handled necessarily.

The flow would be the following:

  • controller asks producer to return a list of desired dns records
  • controller asks consumer for the current list of dns records
  • controller passes list from producer (desired) and list from consumer (current) to plan calculator and retrieves a Plan
  • controller passes Plan to consumer for execution

We chose to represent the necessary actions as three lists as it seems to be the most compatible way of defining it between dns providers. For instance, AWS Route53 doesn't differentiate between creates and updates so it could just merge them into an upsert list before processing. On the other hand, Google CloudDNS doesn't support updates natively and one would have to convert the updates list to a combination of delete+create first. Other consumers will be different but we think those three lists capture all the information they would require.

Inspired by work we had planned for mate: linki/mate#46

@linki
Copy link
Member Author

linki commented Feb 15, 2017

/cc @ideahitme @justinsb @iterion

@ideahitme
Copy link

ideahitme commented Feb 15, 2017

awesome write-up! 👍

this approach will allow us to have a standardised way for managing dnsprovider state and make plugging new dnsprovider fairly simple (in theory :P)

@iterion
Copy link
Contributor

iterion commented Feb 15, 2017

I really like the idea.

I recall from a Slack convo with @justinsb (unfortunately that history is gone now) that one user has many thousands of dns records. So, in the back of our minds we should probably think about how we can do this efficiently at that scale. Perhaps we should target some specific SLA up front?

@Raffo
Copy link
Contributor

Raffo commented Feb 15, 2017

+1 on the great write up and I like the idea.

@ideahitme
Copy link

ideahitme commented Feb 15, 2017

@iterion yes this is definitely something we should consider. Testing for such scenarios is something we should do as well :)

@LappleApple
Copy link
Contributor

+1 @linki, well done

@linki linki added this to the MVP milestone Feb 28, 2017
@linki
Copy link
Member Author

linki commented Mar 6, 2017

Thanks for the +1s :-)

We implemented the first working version of Plan in #26.

@linki linki closed this as completed Mar 6, 2017
lou-lan pushed a commit to lou-lan/external-dns that referenced this issue May 11, 2022
…sigs#15)

This PR improves krew search not to output header when no plugins found.

/fix kubernetes-sigs#13
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

5 participants