Skip to content

Commit

Permalink
Fixed flower, deprecated gevent checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
pomo-mondreganto committed Jan 22, 2022
1 parent c44e6b0 commit 5b313a4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
7 changes: 5 additions & 2 deletions backend/lib/models/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from kombu.utils import json as kjson
from typing import Optional, List, Dict, Any

from kombu.utils import json as kjson

from .base import BaseModel
from .flag import Flag
from .verdict import CheckerVerdict
Expand Down Expand Up @@ -63,7 +64,9 @@ def checker_tags(self) -> List[str]:

@property
def is_checker_gevent_optimized(self) -> bool:
return 'gevent' in self.checker_tags
# Disabling due to major stability issues with Celery + Gevent.
# return 'gevent' in self.checker_tags
return False

@property
def checker_returns_flag_id(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ click-plugins==1.1.1
click-repl==0.2.0
Deprecated==1.2.13
dnspython==1.16.0
eventlet==0.31.0
eventlet==0.30.2
Flask==2.0.2
Flask-Cors==3.0.10
Flask-SocketIO==5.1.1
Expand Down
2 changes: 2 additions & 0 deletions cli/base/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ def setup_redis(config: models.RedisConfig):


def setup_rabbitmq(config: models.RabbitMQConfig):
management_url = f'http://{config.user}:{config.password}@{config.host}:15672/api/'
rabbitmq_config = [
"# THIS FILE IS MANAGED BY 'control.py'",
f'RABBITMQ_HOST={config.host}',
f'RABBITMQ_PORT={config.port}',
f'RABBITMQ_DEFAULT_USER={config.user}',
f'RABBITMQ_DEFAULT_PASS={config.password}',
f'RABBITMQ_DEFAULT_VHOST={config.vhost}',
f'BROKER_API_URL={management_url}',
]

utils.print_bold(f'Writing broker env to {constants.RABBITMQ_ENV_PATH}')
Expand Down
20 changes: 15 additions & 5 deletions docker_config/celery/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ case ${SERVICE} in
echo "[*] Starting celery worker"
celery -A tasks.app \
worker \
-E -l info \
--pool=gevent \
--concurrency=20
-E -l info
;;
"flower")
set +e
echo "[*] Checking if celery is available"
celery -A tasks.app inspect registered
# shellcheck disable=SC2181
while [[ $? != 0 ]]; do
echo "[*] Waiting for celery..."
sleep 5
celery -A tasks.app inspect registered
done
set -e

echo "[*] Starting celery flower"
FLOWER_PORT=${PORT:-5000} \
flower -A tasks.app \
celery -A tasks.app \
flower \
--basic_auth="${ADMIN_USERNAME}:${ADMIN_PASSWORD}" \
--url_prefix=flower \
--address=0.0.0.0
--address=0.0.0.0 \
--broker_api="${BROKER_API_URL}"
;;
esac
17 changes: 12 additions & 5 deletions tests/service/checker/gevent_checker.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import sys

from pathlib import Path
Expand All @@ -7,10 +9,6 @@

from test_service_lib import *

from gevent import monkey

monkey.patch_all()


class Checker(BaseChecker):
def __init__(self, *args, **kwargs):
Expand All @@ -37,5 +35,14 @@ def put(self, flag_id, flag, vuln):

def get(self, flag_id, flag, vuln):
got_flag = self.mch.get_flag(flag_id, vuln)
assert_eq(got_flag, flag, 'Could not get flag', status=Status.CORRUPT)
self.assert_eq(got_flag, flag, 'Could not get flag', status=Status.CORRUPT)
self.cquit(Status.OK)


if __name__ == '__main__':
c = Checker(sys.argv[2])
try:
c.action(sys.argv[1], *sys.argv[3:])
except c.get_check_finished_exception():
cquit(Status(c.status), c.public, c.private)

0 comments on commit 5b313a4

Please sign in to comment.