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

fix(init): uWSGI Snuba API processes not initializing Snuba #3370

Merged
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
2 changes: 1 addition & 1 deletion snuba/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_command(self, ctx: Any, name: str) -> click.Command:
# That way if any command code references any snuba construct that needs
# to be initialized (e.g. a factory) at import time, it is already initialized
# into the runtime
initialize.initialize()
initialize.initialize_snuba()
fn = os.path.join(plugin_folder, actual_command_name + ".py")
with open(fn) as f:
code = compile(f.read(), fn, "exec")
Expand Down
4 changes: 2 additions & 2 deletions snuba/core/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def _load_entities() -> None:
initialize_entity_factory()


def initialize() -> None:
logger.info("Initializing snuba")
def initialize_snuba() -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simple rename to make it easier to understand the usage of this function outside of this module.

logger.info("Initializing Snuba")

# The order of the functions matters The reference direction is
#
Expand Down
2 changes: 2 additions & 0 deletions snuba/web/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from snuba.core.initialize import initialize_snuba
from snuba.environment import setup_logging, setup_sentry

setup_logging()
setup_sentry()
initialize_snuba()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the core change, the snuba/web/wsgi.py file is loaded by uWSGI to start the API process.

Comment on lines 4 to +6
Copy link
Member

Choose a reason for hiding this comment

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

not related to this ticket but I'm starting to think all of these should be in the initialize function


from snuba.web.views import application # noqa
4 changes: 2 additions & 2 deletions test_initialization/test_initialize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import mock

from snuba.core.initialize import initialize
from snuba.core.initialize import initialize_snuba


class TestInitialization:
Expand All @@ -17,7 +17,7 @@ def test_init(
for factory in (_DS_FACTORY, _ENT_FACTORY, _STORAGE_FACTORY):
assert factory is None

initialize()
initialize_snuba()
from snuba.datasets.entities.factory import get_all_entity_names
from snuba.datasets.factory import get_enabled_dataset_names
from snuba.datasets.storages.factory import get_all_storage_keys
Expand Down