Skip to content

Commit

Permalink
Merge pull request #794 from opengisch/rip_redis
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus authored Oct 4, 2023
2 parents ef116a3 + 1ddce5c commit c43a9e2
Show file tree
Hide file tree
Showing 14 changed files with 2 additions and 1,963 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ SENTRY_SAMPLE_RATE=1
# DEFAULT: dev
SENTRY_RELEASE=dev

REDIS_PASSWORD=change_me_with_a_very_loooooooooooong_password
REDIS_PORT=6379

# Memcached port. Exposed only in docker-compose.local.yml
# DEFAULT: 11211
MEMCACHED_PORT=11211
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,6 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: opengisch/qfieldcloud-worker-wrapper:${{ steps.prepare.outputs.tag }}

# Redis
- name: Docker Test Redis
id: docker_test_redis
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker-redis
file: ./docker-redis/Dockerfile

- name: Docker Build and Push Redis
id: docker_build_and_push_redis
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker-redis
file: ./docker-redis/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: opengisch/qfieldcloud-redis:${{ steps.prepare.outputs.tag }}

# QGIS
- name: Docker Test QGIS
id: docker_test_qgis
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ repos:
rev: 'v1.5.1'
hooks:
- id: mypy
additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-redis, types-tabulate, types-jsonschema, django-stubs]
additional_dependencies: [types-pytz, types-Deprecated, types-PyYAML, types-requests, types-tabulate, types-jsonschema, django-stubs]
pass_filenames: false
entry: bash -c 'mypy -p docker-qgis -p docker-app -p docker-redis "$@"' --
entry: bash -c 'mypy -p docker-qgis -p docker-app "$@"' --
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ Based on this example
| nginx https | 443 | WEB_HTTPS_PORT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| django http | 8011 | DJANGO_DEV_PORT | :white_check_mark: | :x: | :x: |
| postgres | 5433 | HOST_POSTGRES_PORT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| redis | 6379 | REDIS_PORT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| memcached | 11211 | MEMCACHED_PORT | :white_check_mark: | :x: | :x: |
| geodb | 5432 | HOST_POSTGRES_PORT | :white_check_mark: | :white_check_mark: | :x: |
| minio API | 8009 | MINIO_API_PORT | :white_check_mark: | :x: | :x: |
Expand Down
5 changes: 0 additions & 5 deletions docker-app/qfieldcloud/core/management/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
results = {}

results["redis"] = "ok"
# Check if redis is visible
if not utils.redis_is_running():
results["redis"] = "error"

results["geodb"] = "ok"
# Check geodb
if not geodb_utils.geodb_is_running():
Expand Down
1 change: 0 additions & 1 deletion docker-app/qfieldcloud/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def setUp(self):
def test_api_status(self):
response = self.client.get("/api/v1/status/")
self.assertTrue(status.is_success(response.status_code))
self.assertEqual(response.json()["redis"], "ok")
self.assertEqual(response.json()["storage"], "ok")
self.assertEqual(response.json()["geodb"], "ok")

Expand Down
13 changes: 0 additions & 13 deletions docker-app/qfieldcloud/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from botocore.errorfactory import ClientError
from django.conf import settings
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
from redis import Redis, exceptions

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -85,18 +84,6 @@ def total_size(self) -> int:
return sum(v.size for v in self.versions if v.size is not None)


def redis_is_running() -> bool:
try:
connection = Redis(
"redis", password=os.environ.get("REDIS_PASSWORD"), port=6379
)
connection.set("foo", "bar")
except exceptions.ConnectionError:
return False

return True


def get_s3_session() -> boto3.Session:
"""Get a new S3 Session instance using Django settings"""

Expand Down
5 changes: 0 additions & 5 deletions docker-app/qfieldcloud/core/views/status_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ def get(self, request):
# Try to get the status from the cache
results = cache.get("status_results", {})
if not results:
results["redis"] = "ok"
# Check if redis is visible
if not utils.redis_is_running():
results["redis"] = "error"

results["geodb"] = "ok"
# Check geodb
if not geodb_utils.geodb_is_running():
Expand Down
1 change: 0 additions & 1 deletion docker-app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pyrsistent==0.19.3
python-dateutil==2.8.2
python3-openid==3.2.0
pytz==2023.3
redis==3.5.3
requests==2.31.0
requests-oauthlib==1.3.1
ruamel.yaml==0.17.26
Expand Down
24 changes: 0 additions & 24 deletions docker-app/wait_for_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from time import sleep, time

import psycopg2
import redis

logger = logging.getLogger()
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -41,26 +40,3 @@ def wait_for_postgres():


wait_for_postgres()


def wait_for_redis():
logger.info("Waiting for redis...")
start_time = time()
while time() - start_time < TIMEOUT:
logger.info("Waiting for redis...")
try:
r = redis.Redis(
host="redis", password=os.environ.get("REDIS_PASSWORD"), db=0
)
if not r.ping():
raise Exception
logger.info("Redis is ready! ✨ 💅")
return True
except Exception as e:
logger.info("Redis isn't ready.\n%s" % e)
sleep(INTERVAL)

return False


wait_for_redis()
5 changes: 0 additions & 5 deletions docker-compose.override.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ services:
command: python3 -m debugpy --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000
depends_on:
- db
- redis

worker_wrapper:
scale: ${QFIELDCLOUD_WORKER_REPLICAS}
Expand Down Expand Up @@ -62,10 +61,6 @@ services:
- ${HOST_POSTGRES_PORT}:5432
command: ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]

redis:
ports:
- "${REDIS_PORT}:6379"

memcached:
ports:
- "${MEMCACHED_PORT}:11211"
Expand Down
14 changes: 0 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ services:
STORAGE_REGION_NAME: ${STORAGE_REGION_NAME}
STORAGE_ENDPOINT_URL: ${STORAGE_ENDPOINT_URL}
QFIELDCLOUD_DEFAULT_NETWORK: ${QFIELDCLOUD_DEFAULT_NETWORK}
REDIS_PASSWORD: ${REDIS_PASSWORD}
GEODB_HOST: ${GEODB_HOST}
GEODB_PORT: ${GEODB_PORT}
GEODB_USER: ${GEODB_USER}
Expand Down Expand Up @@ -87,8 +86,6 @@ services:
ofelia.job-exec.runcrons.no-overlap: "true"
ofelia.job-exec.runcrons.schedule: "@every 1m"
ofelia.job-exec.runcrons.command: python manage.py runcrons
depends_on:
- redis

nginx:
image: nginx:stable
Expand Down Expand Up @@ -141,17 +138,6 @@ services:
command: bash -c "echo QGIS built"
logging: *default-logging

redis:
build:
context: ./docker-redis
network: host
args:
REDIS_PASSWORD: ${REDIS_PASSWORD}
restart: unless-stopped
expose:
- "6379:6379"
logging: *default-logging

worker_wrapper:
<<: *default-django
build:
Expand Down
8 changes: 0 additions & 8 deletions docker-redis/Dockerfile

This file was deleted.

Loading

0 comments on commit c43a9e2

Please sign in to comment.