no docker cleaner
This commit is contained in:
parent
3734ad0354
commit
8ac97d3dd2
@ -266,52 +266,6 @@ services:
|
|||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
docker_cleaner:
|
|
||||||
image: mathwave/sprint-repo:sprint
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
command: ./manage.py docker_cleaner
|
|
||||||
environment:
|
|
||||||
DB_HOST: "postgres"
|
|
||||||
FS_HOST: "storage"
|
|
||||||
RABBIT_HOST: "rabbitmq"
|
|
||||||
REDIS_HOST: "redis"
|
|
||||||
DB_PASSWORD: $DB_PASSWORD
|
|
||||||
DEBUG: $DEBUG
|
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
deploy:
|
|
||||||
mode: global
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
redis_worker:
|
|
||||||
image: mathwave/sprint-repo:sprint
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
command: ./manage.py redis_worker
|
|
||||||
environment:
|
|
||||||
DB_HOST: "postgres"
|
|
||||||
FS_HOST: "storage"
|
|
||||||
RABBIT_HOST: "rabbitmq"
|
|
||||||
REDIS_HOST: "redis"
|
|
||||||
DB_PASSWORD: $DB_PASSWORD
|
|
||||||
DEBUG: $DEBUG
|
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
deploy:
|
|
||||||
mode: replicated
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
file_generator:
|
file_generator:
|
||||||
image: mathwave/sprint-repo:sprint
|
image: mathwave/sprint-repo:sprint
|
||||||
networks:
|
networks:
|
||||||
|
@ -270,52 +270,6 @@ services:
|
|||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
docker_cleaner:
|
|
||||||
image: mathwave/sprint-repo:sprint
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
command: ./manage.py docker_cleaner
|
|
||||||
environment:
|
|
||||||
DB_HOST: "postgres"
|
|
||||||
FS_HOST: "storage"
|
|
||||||
RABBIT_HOST: "rabbitmq"
|
|
||||||
REDIS_HOST: "redis"
|
|
||||||
DB_PASSWORD: $DB_PASSWORD
|
|
||||||
DEBUG: $DEBUG
|
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
deploy:
|
|
||||||
mode: global
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
redis_worker:
|
|
||||||
image: mathwave/sprint-repo:sprint
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
command: ./manage.py redis_worker
|
|
||||||
environment:
|
|
||||||
DB_HOST: "postgres"
|
|
||||||
FS_HOST: "storage"
|
|
||||||
RABBIT_HOST: "rabbitmq"
|
|
||||||
REDIS_HOST: "redis"
|
|
||||||
DB_PASSWORD: $DB_PASSWORD
|
|
||||||
DEBUG: $DEBUG
|
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
deploy:
|
|
||||||
mode: replicated
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
file_generator:
|
file_generator:
|
||||||
image: mathwave/sprint-repo:sprint
|
image: mathwave/sprint-repo:sprint
|
||||||
networks:
|
networks:
|
||||||
|
@ -27,15 +27,5 @@ class DistantTester(BaseTester):
|
|||||||
def notify(self):
|
def notify(self):
|
||||||
self.request("notify")
|
self.request("notify")
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
self.save_solution()
|
|
||||||
self.call(f"docker rm --force solution_{self.solution.id}")
|
|
||||||
self.call(f"docker rm --force solution_{self.solution.id}_checker")
|
|
||||||
for file in self.solution.task.dockerfiles:
|
|
||||||
add_name = file.filename[11:]
|
|
||||||
self.call(f"docker rm --force solution_container_{self.solution.id}_{add_name}")
|
|
||||||
self.call(f"docker image rm solution_image_{self.solution.id}_{add_name}")
|
|
||||||
self.call(f"docker network rm solution_network_{self.solution.id}")
|
|
||||||
|
|
||||||
def save_progress(self):
|
def save_progress(self):
|
||||||
self.request("save_progress")
|
self.request("save_progress")
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
from subprocess import call
|
|
||||||
|
|
||||||
from SprintLib.redis import lock, get_redis
|
|
||||||
from SprintLib.utils import LoopWorker
|
|
||||||
|
|
||||||
|
|
||||||
class Command(LoopWorker):
|
|
||||||
help = "starts docker cleaner"
|
|
||||||
|
|
||||||
@lock("docker")
|
|
||||||
def go(self):
|
|
||||||
containers, images, networks = list(), list(), list()
|
|
||||||
with get_redis() as r:
|
|
||||||
while r.llen("containers") != 0:
|
|
||||||
value = r.rpop("containers").decode("utf-8")
|
|
||||||
return_code = call(f"docker rm --force {value}", shell=True)
|
|
||||||
if return_code != 0:
|
|
||||||
containers.append(value)
|
|
||||||
while r.llen("images") != 0:
|
|
||||||
value = r.rpop("images").decode("utf-8")
|
|
||||||
return_code = call(f"docker image rm --force {value}", shell=True)
|
|
||||||
if return_code != 0:
|
|
||||||
images.append(value)
|
|
||||||
while r.llen("networks") != 0:
|
|
||||||
value = r.rpop("networks").decode("utf-8")
|
|
||||||
return_code = call(f"docker network rm {value}", shell=True)
|
|
||||||
if return_code != 0:
|
|
||||||
networks.append(value)
|
|
||||||
if containers:
|
|
||||||
r.lpush("containers", *containers)
|
|
||||||
if images:
|
|
||||||
r.lpush("images", *images)
|
|
||||||
if networks:
|
|
||||||
r.lpush("networks", *networks)
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
call('docker image rm $(docker images -q mathwave/sprint-repo)', shell=True)
|
|
||||||
print("Old images removed")
|
|
||||||
super().handle(*args, **options)
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
from SprintLib.queue import MessagingSupport
|
|
||||||
from SprintLib.redis import lock, get_redis
|
|
||||||
|
|
||||||
|
|
||||||
class Command(MessagingSupport):
|
|
||||||
help = "Starts redis worker"
|
|
||||||
queue_name = "redis"
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.handlers = {
|
|
||||||
"docker": self.docker_handler
|
|
||||||
}
|
|
||||||
|
|
||||||
@lock("docker")
|
|
||||||
def docker_handler(self, payload):
|
|
||||||
key = payload["key"]
|
|
||||||
value = payload["value"]
|
|
||||||
with get_redis() as r:
|
|
||||||
r.lpush(key, value)
|
|
||||||
|
|
||||||
def process(self, payload: dict):
|
|
||||||
action = payload.get("action")
|
|
||||||
if action is None:
|
|
||||||
raise ValueError("No action field in message")
|
|
||||||
handler = self.handlers.get(action)
|
|
||||||
if handler is None:
|
|
||||||
raise ValueError(f"No handler for action: {action}")
|
|
||||||
handler(payload)
|
|
Loading…
Reference in New Issue
Block a user