Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build
on:
pull_request:
branches: ["**"]
push:
branches:
- main

jobs:
install-tools:
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install all tools
run: make tools
- uses: actions/upload-artifact@v4
with:
name: tools
path: bin/

go-tests:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set executable
run: chmod +x bin/*
- name: Run Go tests
run: make test-go

prometheus-alerts:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set executable
run: chmod +x bin/*
- name: Run Prometheus alert tests
run: make test-prometheus-alerts

prometheus-rules:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set executable
run: chmod +x bin/*
- name: Run Prometheus rules tests
run: make test-prometheus-rules
lint:
needs: install-tools
if: "!contains(github.event.head_commit.message, 'Merge pull request')"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: actions/download-artifact@v4
with:
name: tools
path: bin/
- name: Set executable
run: chmod +x bin/*

- name: Run lint
run: make lint
26 changes: 0 additions & 26 deletions .github/workflows/lint.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/tests.yml

This file was deleted.

18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ dep:
@go mod tidy

lint-benthos: build ## Run Benthos linter
@CLICKHOUSE_HOST="" CLICKHOUSE_PORT="" CLICKHOUSE_SIGNAL_DATABASE="" CLICKHOUSE_INDEX_DATABASE="" CLICKHOUSE_USER="" CLICKHOUSE_PASSWORD="" \
@CLICKHOUSE_HOST="" CLICKHOUSE_PORT="" CLICKHOUSE_DIMO_DATABASE="" CLICKHOUSE_INDEX_DATABASE="" CLICKHOUSE_USER="" CLICKHOUSE_PASSWORD="" \
S3_AWS_ACCESS_KEY_ID="" S3_AWS_SECRET_ACCESS_KEY="" S3_CLOUDEVENT_BUCKET="" S3_EPHEMERAL_BUCKET="" S3_AWS_REGION="" \
dps lint -r ./charts/dps/files/resources.yaml ./charts/dps/files/config.yaml ./charts/dps/files/*
dps lint -r ./charts/dps/files/resources.yaml ./charts/dps/files/config.yaml ./charts/dps/files/streams/*

lint: lint-benthos ## Run linter for benthos config and go code
golangci-lint version
Expand All @@ -69,10 +69,16 @@ test-go: ## Run Go tests

test: test-go test-prom ## run all tests

test-prom: ## run prometheus tests
sed "s/{{ .Release.Namespace }}/dev/g" ./charts/dps/templates/alerts.yaml | sed 's/{{.*}}//g' > tests/prom/alerts-modified.yaml
go tool promtool check rules tests/prom/alerts-modified.yaml
go tool promtool test rules tests/prom/rules-tests.yaml

test-prometheus-prepare: ## Prepare Prometheus alert files for testing
@mkdir -p ./charts/dps/tests
@sed "s/{{ .Release.Namespace }}/dev/g" ./charts/dps/templates/alerts.yaml | sed 's/{{.*}}//g' > ./tests/prom/alerts-modified.yaml

test-prometheus-alerts: test-prometheus-prepare ## Check Prometheus alert rules
@go tool promtool check rules ./tests/prom/alerts-modified.yaml

test-prometheus-rules: test-prometheus-prepare ## Run Prometheus rules tests
@go tool promtool test rules ./tests/prom/rules-tests.yaml

tools-golangci-lint:
@mkdir -p $(PATHINSTBIN)
Expand Down
2 changes: 1 addition & 1 deletion charts/dps/files/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ logger:
add_timestamp: true
format: json
static_fields:
'appname': zone.dimo.dps
'app': zone.dimo.dps
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

makes this consistent with our other services.


metrics:
prometheus: {}
Expand Down
55 changes: 55 additions & 0 deletions charts/dps/files/streams/events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
input:
label: kafka_input
kafka_franz:
seed_brokers:
- ${KAFKA_BOOTSTRAP_SERVERS:localhost}:${KAFKA_BOOTSTRAP_PORT:9092}
topics:
- '${DEVICE_EVENTS_TOPIC:topic.device.events}'
consumer_group: "zone.dimo.dps.events"
client_id: ${CONTAINER_NAME:localhost}-dps-events
rack_id: ${NODE_NAME:localhost}
fetch_max_bytes: 100MiB
fetch_max_wait: 50ms
fetch_min_bytes: 1B
fetch_max_partition_bytes: 10MiB
commit_period: 2s
checkpoint_limit: 1000000 # double the batch size for insertion
start_offset: "latest"

pipeline:
processors:
- label: "convert_events_to_slice"
dimo_event_to_slice: {}

output:
label: "insert_event"
fallback:
- label: "insert_event_clickhouse"
sql_insert:
driver: clickhouse
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_DIMO_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&max_execution_time=600
table: event
columns: []
args_mapping: root = this
batching:
count: 500000
byte_size: 0
period: "2s"
check: ""

- label: "insert_event_clickhouse_failure"
switch:
cases:
# If the error contains "bad connection", reject the message so it will be retried
- check: 'metadata("fallback_error").or("").contains("bad connection")'
output:
reject: metadata("fallback_error")
processors:
- resource: "handle_db_connection_error"
- check: ''
output:
drop: {}
processors:
- mutation: |
meta dimo_component = "insert_event_clickhouse"
- resource: "handle_db_error"
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ input:
pipeline:
processors:
- label: signal_db_migration
dimo_signal_migration:
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_SIGNAL_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&dial_timeout=5s
dimo_db_migration:
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_DIMO_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&dial_timeout=5s

- label: "inputlogger"
for_each:
Expand All @@ -29,16 +29,16 @@ pipeline:
message: 'MessageReceived'
fields_mapping: |
root.payload = this
- label: "convert_to_slice"
signal_to_slice:
- label: "convert_signals_to_slice"
dimo_signal_to_slice: {}

output:
label: "insert_signal"
fallback:
- label: "insert_signal_clickhouse"
sql_insert:
driver: clickhouse
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_SIGNAL_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&max_execution_time=600
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_DIMO_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&max_execution_time=600
table: signal
columns: []
args_mapping: root = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ input:
pipeline:
processors:
- label: "file_index_migration"
dimo_file_index_migration:
dimo_file_index_db_migration:
dsn: clickhouse://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/${CLICKHOUSE_INDEX_DATABASE}?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&secure=true&dial_timeout=5s

- label: "inputlogger"
Expand Down
2 changes: 2 additions & 0 deletions charts/dps/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ metadata:
{{ include "dps.labels" . | indent 4 }}
data:
{{ tpl (.Files.Glob "files/*").AsConfig $ | indent 2 }}
{{ tpl (.Files.Glob ("files/streams/*")).AsConfig $ | indent 2 }}

15 changes: 6 additions & 9 deletions charts/dps/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: signals
mountPath: /streams/signals.yaml
subPath: signals.yaml
- name: valid-cloudevents
mountPath: /streams/valid-cloudevents.yaml
subPath: valid-cloudevents.yaml
- name: partial-cloudevents
mountPath: /streams/partial-cloudevents.yaml
subPath: partial-cloudevents.yaml
{{- $files := .Files.Glob ("files/streams/*") }}
{{- range $path, $_ := $files }}
- name: {{ $path | base | replace "." "-" }}
mountPath: /streams/{{ $path | base }}
subPath: {{ $path | base }}
{{- end }}
- name: config
mountPath: /config
subPath: config.yaml
Expand Down
9 changes: 8 additions & 1 deletion charts/dps/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ securityContext:
env:
KAFKA_BOOTSTRAP_SERVERS: kafka-dev-dimo-kafka-kafka-brokers
DEVICE_SIGNALS_TOPIC: topic.device.signals
DEVICE_EVENTS_TOPIC: topic.device.events
DEVICE_VALID_CE_TOPIC: topic.device.validcloudevents
DEVICE_PARTIAL_CE_TOPIC: topic.device.partialcloudevents
ELASTIC_MULTIPLE_NODE: false
ENVIRONMENT: dev
CLICKHOUSE_PORT: 9440
CLICKHOUSE_SIGNAL_DATABASE: dimo
CLICKHOUSE_DIMO_DATABASE: dimo
CLICKHOUSE_INDEX_DATABASE: file_index
S3_CLOUDEVENT_BUCKET: dimo-ingest-cloudevent-dev
S3_EPHEMERAL_BUCKET: dimo-ingest-ephemeral-dev
Expand Down Expand Up @@ -113,6 +114,12 @@ kafka:
compression.type: producer
cleanup.policy: delete
retention.ms: '7200000'
- name: topic.device.events
config:
segment.ms: '3600000'
compression.type: producer
cleanup.policy: delete
retention.ms: '7200000'
- name: topic.device.validcloudevents
config:
segment.ms: '3600000'
Expand Down
Loading