Skip to content

[Merged by Bors] - Druid DB Connection#71

Closed
fhennig wants to merge 81 commits intomainfrom
druid-connection
Closed

[Merged by Bors] - Druid DB Connection#71
fhennig wants to merge 81 commits intomainfrom
druid-connection

Conversation

@fhennig
Copy link
Copy Markdown
Contributor

@fhennig fhennig commented Jan 13, 2022

Description

This PR refactors the init process and adds a new custom resource for druid connections.

The Init resource is now called SupersetDB and also tracks a status. it is first Provisioned. If possible (secret also deployed) a kubernetes Job is started and the status of the CR becomes Initializing. The job is watched, and depending on whether it successfully completes or not, the SupersetDB also becomes Ready or Failed respectively.

This change allows us to also depend on the DB being ready (or not). This is necessary for writing the druid connection information into the DB.

A new CRD is introduced: DruidConnection. It holds information about the superset DB it should write to, and the Druid cluster that should be connected. A new controller watches the discovery config map as well as the superset DB resources. Once all the dependencies are there (and Ready) a job is started, and the status is updated, just like it is done for the SupersetDB.

This is in line with the declarative philosophy of k8s; the spec reflects the desired state and the status tracks the actual underlying cluster. Also, with multiple controllers watching object states, control flow is delegated a bit to the API server. Before we were watching the job state manually, now we react to status changes which are given to us by the API server. The controllers only react to object changes.

This PR also relies on the Druid Discovery PR stackabletech/druid-operator#102

What wasn't done: If the DruidConnection resource is deleted, the actual connection is not deleted. The issue doesn't say that this is necessary, and there is no obvious, documented way to delete data sources from the commandline, we'd have to go into the database and delete stuff there. On the controller side we can use a finalizer.

Review Checklist

  • Code contains useful comments
  • (Integration-)Test cases added (or not applicable)
  • Documentation added (or not applicable)
  • Changelog updated (or not applicable)
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Once the review is done, comment bors r+ (or bors merge) to merge. Further information

Copy link
Copy Markdown
Member

@maltesander maltesander left a comment

Choose a reason for hiding this comment

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

LGTM.
I had the one comment for namespaces. This is not part of this PR so im happy to merge as is (and create an issue and (or) PR where we address this).

Copy link
Copy Markdown
Member

@maltesander maltesander left a comment

Choose a reason for hiding this comment

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

LGTM.

@fhennig
Copy link
Copy Markdown
Contributor Author

fhennig commented Feb 1, 2022

bors merge

bors bot pushed a commit that referenced this pull request Feb 1, 2022
## Description

This PR refactors the init process and adds a new custom resource for druid connections.

The Init resource is now called SupersetDB and also tracks a status. it is first `Provisioned`. If possible (secret also deployed) a kubernetes `Job` is started and the status of the CR becomes `Initializing`. The job is watched, and depending on whether it successfully completes or not, the SupersetDB also becomes `Ready` or `Failed` respectively.

This change allows us to also depend on the DB being ready (or not). This is necessary for writing the druid connection information into the DB.

A new CRD is introduced: `DruidConnection`. It holds information about the superset DB it should write to, and the Druid cluster that should be connected. A new controller watches the discovery config map as well as the superset DB resources. Once all the dependencies are there (and `Ready`) a job is started, and the status is updated, just like it is done for the `SupersetDB`.

This is in line with the declarative philosophy of k8s; the spec reflects the desired state and the status tracks the actual underlying cluster. Also, with multiple controllers watching object states, control flow is delegated a bit to the API server. Before we were watching the job state manually, now we react to status changes which are given to us by the API server. The controllers only react to object changes.

This PR also relies on the Druid Discovery PR stackabletech/druid-operator#102

What wasn't done: If the DruidConnection resource is deleted, the actual connection is not deleted. The issue doesn't say that this is necessary, and there is no obvious, documented way to delete data sources from the commandline, we'd have to go into the database and delete stuff there. On the controller side we can use a [finalizer](https://github.com/kube-rs/kube-rs/blob/d90ee9706923ceddf94c3d50928bc390543af2fc/examples/secret_syncer.rs#L92-L102).



Co-authored-by: Felix Hennig <fhennig@users.noreply.github.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Feb 1, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Druid DB Connection [Merged by Bors] - Druid DB Connection Feb 1, 2022
@bors bors bot closed this Feb 1, 2022
@bors bors bot deleted the druid-connection branch February 1, 2022 11:06
@fhennig fhennig mentioned this pull request Feb 1, 2022
1 task
stackable-bot added a commit that referenced this pull request Feb 10, 2022
…ackabletech/operator-templating repo.

Original commit message:
Adds missing --- start token to please yamllint (#71)
bors bot pushed a commit that referenced this pull request Feb 10, 2022
Automatically created PR based on commit 5da434fdc7a60487b12badfdc8c5458dfb4b66da in stackabletech/operator-templating repo.

Original commit message:
Adds missing --- start token to please yamllint (#71)
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.

4 participants