Skip to content

Commit

Permalink
1258 new branch use shared models in worker (#415)
Browse files Browse the repository at this point in the history
* wip

* add new apps + got rid of settings in the db shared settings

* update to correct shared

* update shared

* update to latest shared

* another shared to try

* another shared sha

* test migration staging

* add timeseries migrate command

* updated shared sha

* fix prod retry_in issue
  • Loading branch information
adrian-codecov committed May 1, 2024
1 parent f9f6888 commit 13536e9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 99 deletions.
Empty file.
83 changes: 0 additions & 83 deletions django_scaffold/management/commands/migrate.py

This file was deleted.

43 changes: 33 additions & 10 deletions django_scaffold/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,56 @@
IS_DEV = os.getenv("RUN_ENV") == "DEV"

# Application definition

INSTALLED_APPS = [
"django_scaffold", # must be first to override migrate command
"shared.django_apps.legacy_migrations",
"shared.django_apps.codecov_auth",
"shared.django_apps.core",
"shared.django_apps.reports",
"shared.django_apps.pg_telemetry",
"shared.django_apps.ts_telemetry",
"shared.django_apps.rollouts",
"shared.django_apps.user_measurements",
"psqlextra",
# Needed to install legacy migrations
"django.contrib.admin",
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.messages",
"django.contrib.sessions",
]

TELEMETRY_VANILLA_DB = "default"
TELEMETRY_TIMESCALE_DB = "timeseries"

DATABASE_ROUTERS = [
"shared.django_apps.db_routers.TelemetryDatabaseRouter",
"shared.django_apps.db_routers.MultiDatabaseRouter",
]

SKIP_RISKY_MIGRATION_STEPS = get_config("migrations", "skip_risky_steps", default=False)

MIDDLEWARE = []
MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
]

TEMPLATES = []
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.contrib.auth.context_processors.auth",
"django.template.context_processors.request",
"django.contrib.messages.context_processors.messages",
]
},
}
]

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = []


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

Expand Down
11 changes: 11 additions & 0 deletions migrate-timeseries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

echo "Running Timeseries Django migrations"
prefix=""
if [ -f "/usr/local/bin/berglas" ]; then
prefix="berglas exec --"
fi

$prefix python manage.py migrate --database timeseries rollouts
$prefix python manage.py migrate --database timeseries pg_telemetry
$prefix python manage.py migrate --database timeseries ts_telemetry
4 changes: 2 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
https://github.com/codecov/shared/archive/5df0e67bbe5093750a4bb48871e825b694d8f338.tar.gz#egg=shared
https://github.com/codecov/shared/archive/f8e95d52d6182d4fc4d5492d5eea50e045a8b51c.tar.gz#egg=shared
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
https://github.com/codecov/test-results-parser/archive/5515e960d5d38881036e9127f86320efca649f13.tar.gz#egg=test-results-parser
boto3>=1.34
celery>=5.3.6
click
codecov-ribs
coverage
django-postgres-extra>=2.0.8
factory-boy
google-cloud-storage>=2.10.0
httpx
Expand All @@ -20,7 +21,6 @@ pytest-asyncio
pytest-cov
pytest-celery
pytest-django
django-postgres-extra>=2.0.8
pytest-mock
pytest-sqlalchemy
pytest-freezegun
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile
# pip-compile requirements.in
#
amqp==5.2.0
# via kombu
Expand Down Expand Up @@ -374,7 +374,7 @@ sentry-sdk==1.40.0
# via
# -r requirements.in
# shared
shared @ https://github.com/codecov/shared/archive/5df0e67bbe5093750a4bb48871e825b694d8f338.tar.gz
shared @ https://github.com/codecov/shared/archive/f8e95d52d6182d4fc4d5492d5eea50e045a8b51c.tar.gz
# via -r requirements.in
six==1.16.0
# via
Expand Down Expand Up @@ -429,6 +429,7 @@ typing==3.7.4.3
typing-extensions==4.6.3
# via
# asgiref
# kombu
# openai
# opentelemetry-sdk
# pydantic
Expand Down
2 changes: 1 addition & 1 deletion tasks/upload_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def run_impl(
)
except LockError:
max_retry = 200 * 3**self.request.retries
retry_in = min(random.randint(max_retry / 2, max_retry), 60 * 60 * 5)
retry_in = min(random.randint(max_retry // 2, max_retry), 60 * 60 * 5)
log.warning(
"Unable to acquire lock for key %s. Retrying",
lock_name,
Expand Down

0 comments on commit 13536e9

Please sign in to comment.