Skip to content

Commit

Permalink
Merge pull request #1019 from ImageMarkup/elasticsearch
Browse files Browse the repository at this point in the history
Use Elasticsearch from new production infrastructure
  • Loading branch information
brianhelba authored Nov 22, 2024
2 parents 2e849af + bf90a9a commit 4debd0c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
tox
env:
DJANGO_DATABASE_URL: postgres://postgres:postgres@localhost:5432/django
DJANGO_ISIC_ELASTICSEARCH_URI: http://elastic:elastic@localhost:9200
DJANGO_ELASTICSEARCH_URL: http://elastic:elastic@localhost:9200
DJANGO_MINIO_STORAGE_ENDPOINT: localhost:9000
DJANGO_MINIO_STORAGE_ACCESS_KEY: minioAccessKey
DJANGO_MINIO_STORAGE_SECRET_KEY: minioSecretKey
Expand Down
4 changes: 2 additions & 2 deletions dev/.env.docker-compose
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
DJANGO_SETTINGS_MODULE=isic.settings.development
DJANGO_DATABASE_URL=postgres://postgres:postgres@postgres:5432/django
DJANGO_CELERY_BROKER_URL=amqp://rabbitmq:5672/
DJANGO_DATABASE_URL=postgres://postgres:postgres@postgres:5432/django
DJANGO_ELASTICSEARCH_URL=http://elastic:elastic@elasticsearch:9200
DJANGO_MINIO_STORAGE_ENDPOINT=minio:9000
DJANGO_MINIO_STORAGE_ACCESS_KEY=minioAccessKey
DJANGO_MINIO_STORAGE_SECRET_KEY=minioSecretKey
DJANGO_STORAGE_BUCKET_NAME=django-storage
DJANGO_MINIO_STORAGE_MEDIA_URL=http://localhost:9000/django-storage
DJANGO_ISIC_ELASTICSEARCH_URI=http://elastic:elastic@elasticsearch:9200
DJANGO_REDIS_URL=redis://localhost:6379/0
DJANGO_ISIC_DATACITE_USERNAME="fakeuser"
DJANGO_ISIC_DATACITE_PASSWORD="fakepassword"
4 changes: 2 additions & 2 deletions dev/.env.docker-compose-native
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DJANGO_SETTINGS_MODULE=isic.settings.development
DJANGO_DATABASE_URL=postgres://postgres:postgres@localhost:5432/django
DJANGO_CELERY_BROKER_URL=amqp://localhost:5672/
DJANGO_DATABASE_URL=postgres://postgres:postgres@localhost:5432/django
DJANGO_ELASTICSEARCH_URL=http://elastic:elastic@elasticsearch:9200
DJANGO_MINIO_STORAGE_ENDPOINT=localhost:9000
DJANGO_MINIO_STORAGE_ACCESS_KEY=minioAccessKey
DJANGO_MINIO_STORAGE_SECRET_KEY=minioSecretKey
DJANGO_STORAGE_BUCKET_NAME=django-storage
DJANGO_ISIC_ELASTICSEARCH_URI=http://elastic:elastic@localhost:9200
DJANGO_REDIS_URL=redis://localhost:6379/0
DJANGO_ISIC_DATACITE_USERNAME="fakeuser"
DJANGO_ISIC_DATACITE_PASSWORD="fakepassword"
2 changes: 1 addition & 1 deletion isic/core/migrations/0003_auto_20240701_1459.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _block_until_elasticsearch_is_available():

while True:
try:
requests.get(f"{settings.ISIC_ELASTICSEARCH_URI}/_cluster/health", timeout=1)
requests.get(f"{settings.ELASTICSEARCH_URL}/_cluster/health", timeout=1)
except requests.exceptions.ConnectionError:
time.sleep(1)
time_slept += 1
Expand Down
2 changes: 1 addition & 1 deletion isic/core/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def perform_request(self, *args: Any, **kwargs: Any) -> Any:

# TODO: investigate using retryable requests with transport_class
RetryOnTimeoutTransport = partial(InstrumentedTransport, retry_on_timeout=True) # noqa: N806
return OpenSearch(settings.ISIC_ELASTICSEARCH_URI, transport_class=RetryOnTimeoutTransport) # type: ignore[arg-type]
return OpenSearch(settings.ELASTICSEARCH_URL, transport_class=RetryOnTimeoutTransport) # type: ignore[arg-type]


def maybe_create_index(index: str, mappings: Mapping[str, Any]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion isic/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _oauth2_pkce_required(client_id):
# with both methods.
ISIC_USE_ELASTICSEARCH_COUNTS = False

ISIC_ELASTICSEARCH_URI = os.environ.get("DJANGO_ISIC_ELASTICSEARCH_URI")
ELASTICSEARCH_URL = os.environ.get("DJANGO_ELASTICSEARCH_URL")
ISIC_ELASTICSEARCH_IMAGES_INDEX = "isic"
ISIC_ELASTICSEARCH_LESIONS_INDEX = "isic-lesions"
ISIC_GUI_URL = "https://www.isic-archive.com/"
Expand Down
1 change: 0 additions & 1 deletion isic/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
ISIC_DATACITE_USERNAME = os.environ["DJANGO_ISIC_DATACITE_USERNAME"]
ISIC_DATACITE_PASSWORD = os.environ["DJANGO_ISIC_DATACITE_PASSWORD"]

ISIC_ELASTICSEARCH_URI = os.environ["SEARCHBOX_URL"]
ISIC_USE_ELASTICSEARCH_COUNTS = True

CACHES = {
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ commands =
passenv =
DJANGO_CELERY_BROKER_URL
DJANGO_DATABASE_URL
DJANGO_ELASTICSEARCH_URL
DJANGO_MINIO_STORAGE_ACCESS_KEY
DJANGO_MINIO_STORAGE_ENDPOINT
DJANGO_MINIO_STORAGE_SECRET_KEY
DJANGO_ISIC_ELASTICSEARCH_URI
DJANGO_REDIS_URL
extras =
dev
Expand Down Expand Up @@ -74,10 +74,10 @@ commands =
passenv =
DJANGO_CELERY_BROKER_URL
DJANGO_DATABASE_URL
DJANGO_ELASTICSEARCH_URL
DJANGO_MINIO_STORAGE_ACCESS_KEY
DJANGO_MINIO_STORAGE_ENDPOINT
DJANGO_MINIO_STORAGE_SECRET_KEY
DJANGO_ISIC_ELASTICSEARCH_URI
DJANGO_REDIS_URL
extras =
dev
Expand All @@ -93,10 +93,10 @@ setenv =
passenv =
DJANGO_CELERY_BROKER_URL
DJANGO_DATABASE_URL
DJANGO_ELASTICSEARCH_URL
DJANGO_MINIO_STORAGE_ACCESS_KEY
DJANGO_MINIO_STORAGE_ENDPOINT
DJANGO_MINIO_STORAGE_SECRET_KEY
DJANGO_ISIC_ELASTICSEARCH_URI
DJANGO_REDIS_URL
extras =
dev
Expand Down

0 comments on commit 4debd0c

Please sign in to comment.