Skip to content

Commit

Permalink
Merge pull request #232 from asmorodskyi/cleanup_in_container
Browse files Browse the repository at this point in the history
Make cleanup calls executed in separate container
  • Loading branch information
asmorodskyi authored Mar 23, 2023
2 parents a28d364 + 3a56eda commit bc8d7a3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY requirements.txt /pcw/
# * Install system requirements
# * Install pip requirements
# * Empty system cache to conserve some space
RUN zypper -n in gcc libffi-devel aws-cli && pip install --no-cache-dir -r /pcw/requirements.txt && rm -rf /var/cache
RUN zypper -n in gcc libffi-devel && pip install --no-cache-dir -r /pcw/requirements.txt && rm -rf /var/cache

# Copy program files only
COPY ocw /pcw/ocw/
Expand All @@ -29,4 +29,4 @@ VOLUME /pcw/db
EXPOSE 8000/tcp

# Once we are certain that this runs nicely, replace this with ENTRYPOINT.
CMD ["/pcw/container-startup", "run"]
ENTRYPOINT ["/pcw/container-startup", "run"]
2 changes: 1 addition & 1 deletion Dockerfile_dev
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY requirements.txt requirements_test.txt requirements_k8s.txt /tmp/
# * Install system requirements
# * Install pip requirements
# * Empty system cache to conserve some space
RUN zypper -n in gcc libffi-devel aws-cli && pip install --no-cache-dir -r /tmp/requirements_test.txt && rm -rf /var/cache
RUN zypper -n in gcc libffi-devel && pip install --no-cache-dir -r /tmp/requirements_test.txt && rm -rf /var/cache

WORKDIR /pcw

Expand Down
3 changes: 3 additions & 0 deletions container-startup
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ case "$CMD" in
"updaterun")
python3 manage.py updaterun
;;
"cleanup")
python3 manage.py cleanup
;;
"rmclusters")
python3 manage.py rmclusters
;;
Expand Down
2 changes: 0 additions & 2 deletions ocw/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def ready(self):

try:
import ocw.lib.db
import ocw.lib.cleanup

ocw.lib.db.init_cron()
ocw.lib.cleanup.init_cron()
except Exception:
logger.exception("Failure on initialize cronjobs")
6 changes: 0 additions & 6 deletions ocw/lib/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ocw.lib.gce import GCE
from ocw.lib.eks import EKS
from ocw.lib.emailnotify import send_mail, send_cluster_notification
from ocw.apps import getScheduler
from ocw.enums import ProviderChoice

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -42,8 +41,3 @@ def list_clusters():
except Exception as ex:
logger.exception("[%s] List clusters failed!", namespace)
send_mail('{} on List clusters in [{}]'.format(type(ex).__name__, namespace), traceback.format_exc())


def init_cron():
getScheduler().add_job(cleanup_run, trigger='interval', minutes=60, id='cleanup_all', misfire_grace_time=1800)
getScheduler().add_job(list_clusters, trigger='interval', hours=18, id='list_clusters', misfire_grace_time=10000)

0 comments on commit bc8d7a3

Please sign in to comment.