Skip to content

Commit

Permalink
Allow custom connector names (#44)
Browse files Browse the repository at this point in the history
* Allow custom connector names

* Update README

* Add connector name verification task
  • Loading branch information
teddyphreak authored Jul 4, 2023
1 parent c1d9c05 commit b0f9213
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 10 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ metabase:
cdc:
postgres:
- hostname: pagilahost
connector: pagila-connector
id: pagila
dbname: pagila
exclude:
Expand All @@ -55,6 +56,10 @@ zalando:
class: standard
```

The following fields are immutable; modifying them will leave an orphan DB replication slot and _will_ result in space exhaustion:
* `cdc.postgres[*].id`
* `cdc.postgres[*].partitions[*].sink`

## Roadmap
In order of priority
* Create python package for maintenance operations
Expand Down
4 changes: 2 additions & 2 deletions charts/dataplane/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.15
version: 0.1.16

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.1.15
appVersion: 0.1.16
11 changes: 7 additions & 4 deletions charts/dataplane/templates/strimzi/connector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

{{- range $db := .Values.cdc.postgres }}
{{- $dbId := required "database id is required" $db.id }}
{{- $dbConnectorName := lower (printf "%s-%s" $fullName $dbId) }}
{{- $dbSlotName := $dbConnectorName | replace "-" "_" }}
{{- $dbSlotName := lower $dbId | replace "." "-" }}
{{- $exclude := list }}
{{- $include := list }}

{{- $dbConnector := $db.connector | default $dbId }}
{{- $dbConnectorName := lower $dbConnector | replace "." "-" }}

{{- if and (hasKey $db "exclude") (hasKey $db "include") }}
{{- fail "table excludes and includes are mutually exclusive" }}
{{- end }}
Expand Down Expand Up @@ -87,7 +89,8 @@ spec:
{{- $partitionSource := required "partition source is required" $partition.source }}
{{- $partitionSink := required "partition sink is required" $partition.sink }}
{{- $partitionConnectorName := lower (printf "%s-%s" $dbConnectorName $partitionSink) | replace "." "-" }}
{{- $partitionSlotName := $partitionConnectorName | replace "-" "_" }}
{{- $partitionSlot := lower (printf "%s_%s" $dbSlotName $partitionSink) }}
{{- $partitionSlotName := $partitionSlot | replace "." "-" | replace "-" "_" }}
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaConnector
Expand Down Expand Up @@ -131,7 +134,7 @@ spec:
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaConnector
metadata:
name: {{ $fullName }}-warehouse-sink
name: {{ $fullName }}-warehouse-postgresql
labels:
strimzi.io/cluster: {{ $fullName }}
spec:
Expand Down
6 changes: 3 additions & 3 deletions charts/dataplane/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ util:
image:
repository: nephelaiio/dataplane-util
pullPolicy: IfNotPresent
tag: dataplane-0.1.14
tag: dataplane-0.1.16
resources: {}

cdc:
Expand Down Expand Up @@ -45,7 +45,7 @@ strimzi:
connect:
image:
repository: nephelaiio/dataplane-connect
tag: dataplane-0.1.14
tag: dataplane-0.1.16
replicas: 1
config:
group.id: connect-cluster
Expand Down Expand Up @@ -100,7 +100,7 @@ metabase:
image:
repository: nephelaiio/dataplane-util
pullPolicy: IfNotPresent
tag: dataplane-0.1.14
tag: dataplane-0.1.16
securityContext: {}

image:
Expand Down
1 change: 1 addition & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ provisioner:
- hostname: "{{ dataplane_pagila_team }}-{{ dataplane_pagila_db }}"
port: 5432
id: pagila
connector: pagila-connector
dbname: "{{ dataplane_pagila_db }}"
signaling: "{{ dataplane_pagila_signaling }}"
exclude:
Expand Down
16 changes: 16 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
- name: fail verification
ansible.builtin.fail:

- name: validate kafka connector name
ansible.builtin.fail:
msg: "connector dataplane-connector was not found"
vars:
connector_matches: "{{ connector_query | selectattr('metadata.name', 'equalto', 'pagila-connector') | length }}"
connector_present: "{{ connector_matches | int > 0 }}"
connector_query: "{{
query(
'kubernetes.core.k8s',
api_version='',
kind='KafkaConnector',
kubeconfig=k8s_kubeconfig
) }}"
until: connector_present
failed_when: not connector_present

- name: wait for cdc to complete
pause:
minutes: 5
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dataplane"
version = "0.1.15"
version = "0.1.16"
description = ""
authors = ["Teodoro Cook <[email protected]>"]

Expand Down
1 change: 1 addition & 0 deletions values.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metabase:
cdc:
postgres:
- hostname: pagilahost
connector: pagila-connector
id: pagila
dbname: pagila
exclude:
Expand Down

0 comments on commit b0f9213

Please sign in to comment.