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

feat: Add crons task consumers #3106

Merged
merged 3 commits into from
Jun 4, 2024
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
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ services:
ingest-monitors:
<<: *sentry_defaults
command: run consumer --no-strict-offset-reset ingest-monitors --consumer-group ingest-monitors
monitors-clock-tick:
<<: *sentry_defaults
command: run consumer --no-strict-offset-reset monitors-clock-tick --consumer-group monitors-clock-tick
monitors-clock-tasks:
<<: *sentry_defaults
command: run consumer --no-strict-offset-reset monitors-clock-tasks --consumer-group monitors-clock-tasks
post-process-forwarder-errors:
<<: *sentry_defaults
command: run consumer post-process-forwarder-errors --consumer-group post-process-forwarder --synchronize-commit-log-topic=snuba-commit-log --synchronize-commit-group=snuba-consumers
Expand Down
9 changes: 8 additions & 1 deletion install/create-kafka-topics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ done

# XXX(BYK): We cannot use auto.create.topics as Confluence and Apache hates it now (and makes it very hard to enable)
EXISTING_KAFKA_TOPICS=$($dc exec -T kafka kafka-topics --list --bootstrap-server kafka:9092 2>/dev/null)
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles ingest-occurrences ingest-metrics ingest-performance-metrics ingest-monitors"
NEEDED_KAFKA_TOPICS="ingest-attachments ingest-transactions ingest-events ingest-replay-recordings profiles ingest-occurrences ingest-metrics ingest-performance-metrics ingest-monitors monitors-clock-tasks"
for topic in $NEEDED_KAFKA_TOPICS; do
if ! echo "$EXISTING_KAFKA_TOPICS" | grep -qE "(^| )$topic( |$)"; then
$dc exec kafka kafka-topics --create --topic $topic --bootstrap-server kafka:9092
echo ""
fi
done

# This topic must have only a single partition for the consumer to work correctly
# https://github.com/getsentry/ops/blob/7dbc26f39c584ec924c8fef2ad5c532d6a158be3/k8s/clusters/us/_topicctl.yaml#L288-L295

if ! echo "$EXISTING_KAFKA_TOPICS" | grep -qE "(^| )monitors-clock-tick( |$)"; then
$dc exec kafka kafka-topics --create --topic monitors-clock-tick --bootstrap-server kafka:9092 --partitions 1
fi
Comment on lines +25 to +30
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: What would happen if someone accidentally created more than 1 partition for this exact topic?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would cause inconsistencies in the ordering of tasks and likely cause weird behaviour. If you've done so I'd recommend repartitioning to have a single partition


echo "${_endgroup}"
Loading