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

feat: Add crons task consumers #3106

merged 3 commits into from
Jun 4, 2024

Conversation

wedamija
Copy link
Member

@wedamija wedamija commented Jun 3, 2024

We now process tasks via Kafka consumers instead of celerybeat. This needs to be added to self-hosted as well

We now process tasks via Kafka consumers instead of celerybeat. This needs to be added to self-hosted as well
Copy link
Member

@evanpurkhiser evanpurkhiser left a comment

Choose a reason for hiding this comment

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

Looks good to me. Will let oss team look to approve

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.01%. Comparing base (c40b153) to head (d5c516f).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3106   +/-   ##
=======================================
  Coverage   99.01%   99.01%           
=======================================
  Files           3        3           
  Lines         203      203           
=======================================
  Hits          201      201           
  Misses          2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@hubertdeng123 hubertdeng123 left a comment

Choose a reason for hiding this comment

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

Recently we've rewritten integration tests for self-hosted in python so hopefully tests are much easier to write. How difficult would it be to add a test to make sure this change is working as intended?

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
$dc exec kafka kafka-topics --create --topic monitors-clock-tick --bootstrap-server kafka:9092 --partitions 1
Copy link
Member

Choose a reason for hiding this comment

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

Should we check to see if topic already exists here before trying to create?

@wedamija
Copy link
Member Author

wedamija commented Jun 3, 2024

Recently we've rewritten integration tests for self-hosted in python so hopefully tests are much easier to write. How difficult would it be to add a test to make sure this change is working as intended?

I'm not totally sure if it's worth writing an integration test here. The code is well tested in Sentry, and it feels like we'd just be duplicating work. It feels like to avoid these kinds of problems it'd be more helpful to figure out how to share these kinds of configs with how things work in prod, or maybe have a way to signal that certain consumers should always be run in self hosted?

@hubertdeng123
Copy link
Member

It feels like to avoid these kinds of problems it'd be more helpful to figure out how to share these kinds of configs with how things work in prod, or maybe have a way to signal that certain consumers should always be run in self hosted?

What was the process for rolling this out to single tenant/prod? Ideally, maybe the way to go about this is to have features link to required consumers/infrastructure components and throw a warning or error in tests when pieces of infrastructure are not enabled for self-hosted?

Comment on lines +25 to +30
# 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
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

@wedamija wedamija merged commit f8e95ec into master Jun 4, 2024
13 checks passed
@wedamija wedamija deleted the danf/crons-task-consumers branch June 4, 2024 17:35
@BYK
Copy link
Member

BYK commented Jun 14, 2024

Is it also time to consider a unified Sentry consumer at this point?

@wedamija
Copy link
Member Author

Is it also time to consider a unified Sentry consumer at this point?

There's a project in the works to move a lot of celery over to Kafka, so this is being considered

jamesbaber1 pushed a commit to Algo-Trading-Tools/sentry that referenced this pull request Jun 20, 2024
We now process tasks via Kafka consumers instead of celerybeat. This needs to be added to self-hosted as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants