-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Explicitly initialize snuba take 2 #3326
Conversation
# IMPORTANT!!!! | ||
# Click replaces underscores with dashes for command names | ||
# by default. To mimic this behavior we have to do that here | ||
# since all of our infrastructure depends on this being the | ||
# case | ||
actual_command_name = name.replace("-", "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bulk of the change
# IMPORTANT!!!! | ||
# Click replaces underscores with dashes for command names | ||
# by default. To mimic this behavior we have to do that here | ||
# since all of our infrastructure depends on this being the | ||
# case | ||
rv.append(filename[:-3].replace("_", "-")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bulk of the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am OK with this change, but it feels a little brittle. If someone checks in a file with an actual dash in it, this will break again.
True but presumably they would run the command at least once before checking it in |
Compiling changes in #3311 and #3326 and moving the initialization up before subcommand compilation The deploy of #3326 caused a crashloop on `snuba-generic-metrics-distributions-subscriptions-scheduler-production`and `snuba-generic-metrics-distributions-subscriptions-scheduler-production` (and only those two) This happened because: 1. generic_metrics entities are defined in config 2. the subscriptions scheduler cli has the entity argument defined like so: ``` @click.option( "--entity", "entity_name", required=True, type=click.Choice([entity_key.value for entity_key in EntityKey]), help="The entity to target", ) ``` This makes the cli depend on the entity key being fully populated *at import time*. This also makes it so that the code as is only work *by accident*. ## The fix We move up initialization *before* we compile the subcommand code so that all the entity factories are initialized at import time ## The test This issue was reproducible locally by trying to run those consumer groups `snuba devserver` did not call those commands either. They have been added. Undoing the fix will make this command fail: ``` SEPARATE_SCHEDULER_EXECUTOR_SUBSCRIPTIONS_DEV=1 ENABLE_METRICS_SUBSCRIPTIONS=1 ENABLE_SENTRY_METRICS_DEV=1 snuba devserver ```
This is mostly the same as #3311 with the only difference being the name transformation
if you have a click command like this:
it will be accessible in the cli as
my-command
. #3311 naively expected it to bemy_command
.This PR fixes that and adds a comment explaining why it's important
Testing
Today I remembered about the
snuba devserver
command which starts up everything with the correct names. If I had done that initially I wouldn't have had to revert.With this change,
snuba devserver
starts up properly (before it did not)