Skip to content

Commit

Permalink
Add rocky worker service to debian packages (#3619)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Klopper <[email protected]>
Co-authored-by: Jeroen Dekkers <[email protected]>
Co-authored-by: stephanie0x00 <[email protected]>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent 825a173 commit 9068e7b
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_debian_packages_on_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jobs:
sudo sed -i "s/BYTES_PASSWORD=\$/BYTES_PASSWORD=$(sudo grep BYTES_PASSWORD /etc/kat/bytes.conf | awk -F'=' '{ print $2 }')/" /etc/kat/mula.conf
- name: Restart KAT
run: sudo systemctl restart kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
run: sudo systemctl restart kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

- name: Setup accounts in Rocky
run: |
Expand Down
2 changes: 1 addition & 1 deletion boefjes/boefjes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _fill_queue(self, task_queue: Queue, queue_type: WorkerManager.Queue):
except HTTPError:
# Scheduler is having issues, so make note of it and try again
logger.exception("Getting the queues from the scheduler failed")
time.sleep(10 * self.settings.poll_interval) # But not immediately
time.sleep(self.settings.poll_interval) # But not immediately
return

# We do not target a specific queue since we start one runtime for all organisations
Expand Down
18 changes: 18 additions & 0 deletions docker-compose.release-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ services:
rocky:
restart: on-failure
depends_on:
- rocky_worker
- octopoes_api_worker
- octopoes_api
- postgres
Expand All @@ -108,12 +109,29 @@ services:
ports:
- "127.0.0.1:8000:8000"
image: "ghcr.io/minvws/nl-kat-rocky:${KAT_VERSION}"
command: web
env_file:
- .env-prod
- .env
environment:
- DATABASE_MIGRATION=true

rocky_worker:
restart: on-failure
depends_on:
- octopoes_api_worker
- octopoes_api
- postgres
- boefje
- normalizer
- katalogus
- scheduler
image: "ghcr.io/minvws/nl-kat-rocky:${KAT_VERSION}"
command: worker
env_file:
- .env-prod
- .env

bytes:
restart: on-failure
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ services:
target: dev
args:
ENVIRONMENT: dev
command: python3 manage.py worker
command: worker
volumes:
- ./rocky:/app/rocky
- ./octopoes/octopoes:/app/rocky/octopoes
Expand Down
4 changes: 3 additions & 1 deletion docs/source/installation_and_deployment/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ By default OpenKAT has an IPv6 subnet configured. This configuration (step 4 and

## Container commands

We have two container images that are used to run multiple containers. What the container runs is be specified by overriding the CMD of the container.
We have three container images that are used to run multiple containers. What the container runs is be specified by overriding the CMD of the container.

| Container image | CMD | Description |
| --------------- | ----------- | --------------------------------------------------------------------------------- |
| rocky | web | Django web application |
| rocky | worker | Rocky reports runner |
| boefjes | boefje | Boefjes runtime |
| boefjes | normalizer | Normalizers runtime |
| boefjes | katalogus | Katalogus API |
Expand Down
6 changes: 3 additions & 3 deletions docs/source/installation_and_deployment/debianinstall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ After finishing these steps, you should restart KAT to load the new configuratio

.. code-block:: sh
sudo systemctl restart kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl restart kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
Start KAT on system boot
========================
Expand All @@ -301,7 +301,7 @@ To start KAT when the system boots, enable all KAT services:

.. code-block:: sh
sudo systemctl enable kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl enable kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
Configure reverse proxy
Expand Down Expand Up @@ -423,4 +423,4 @@ Restart all processes:

.. code-block:: sh
sudo systemctl restart kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl restart kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The relevant services for OpenKAT:
* kat-octopoes.service
* kat-keiko.service
* kat-rocky.service
* kat-rocky-worker.service
* kat-boefjes.service
* kat-katalogus.service
* kat-octopoes-worker.service
Expand Down
26 changes: 26 additions & 0 deletions docs/source/release_notes/1.18.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
============================================
OpenKAT 1.18
============================================

New Features
============


Bug fixes
=========


Upgrading
=========

Debian packages
---------------

If you are using the :ref:`Scripts` we provide to install/upgrade OpenKAT you
need to get the latest version that includes the kat-rocky-worker service.

Full Changelog
==============

The full changelog can be found on `Github
<https://github.com/minvws/nl-kat-coordination/releases/tag/v1.18.0>`_.
18 changes: 18 additions & 0 deletions rocky/debian/kat-rocky-worker.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=kat-rocky worker
After=network.target

[Service]
User=kat
Group=kat
SyslogIdentifier=kat-rocky-worker
WorkingDirectory=/opt/venvs/kat-rocky/
EnvironmentFile=/usr/lib/kat/rocky.defaults
EnvironmentFile=/etc/kat/rocky.conf
ExecStart=/usr/bin/rocky-cli worker
Restart=on-failure
RestartSec=3s
KillMode=mixed

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions rocky/debian/kat-rocky.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[Unit]
Description=kat-rocky daemon
Requires=kat-rocky-worker.service
After=network.target

[Service]
Expand Down
4 changes: 4 additions & 0 deletions rocky/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ override_dh_virtualenv:
override_dh_gencontrol:
dh_gencontrol -- -Vpython=`py3versions -d`

override_dh_installsystemd:
dh_installsystemd --name=kat-rocky
dh_installsystemd --name=kat-rocky-worker

execute_after_dh_install:
dh_installsysusers
6 changes: 6 additions & 0 deletions rocky/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ if [ "$DATABASE_MIGRATION" = "1" ] || [[ $DATABASE_MIGRATION == "true" ]]; then
python manage.py migrate --noinput
fi

if [ "$1" = "web" ]; then
exec granian --interface wsgi rocky.wsgi:application --host 0.0.0.0
elif [ "$1" = "worker" ]; then
exec python3 manage.py worker
fi

exec "$@"
2 changes: 1 addition & 1 deletion rocky/reports/runner/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _fill_queue(self, task_queue: Queue):
except HTTPError:
# Scheduler is having issues, so make note of it and try again
logger.exception("Getting the queues from the scheduler failed")
time.sleep(10 * self.poll_interval) # But not immediately
time.sleep(self.poll_interval) # But not immediately
return

# We do not target a specific queue since we start one runtime for all organisations
Expand Down
4 changes: 2 additions & 2 deletions scripts/installation/openkat-empty-job-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Stop openKAT
echo "Stopping openKAT processes"
sudo systemctl stop xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl stop xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

# Start postgres, switch to the mula_db and empty the job queue
echo "Emptying job queue"
Expand All @@ -13,6 +13,6 @@ EOF

# Start openKAT
echo "Starting openKAT processes"
sudo systemctl start xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl start xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

echo "End of script. It might take a few more seconds for OpenKAT to be fully started and available."
4 changes: 2 additions & 2 deletions scripts/installation/openkat-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ echo "Step 6.11 - Set kat permissions in rabbitmq"
sudo rabbitmqctl set_permissions -p "kat" "kat" ".*" ".*" ".*"

echo "Step 7 - Configure start at system boot"
sudo systemctl enable kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl enable kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

echo "Step 8 - Restart OpenKAT"
sudo systemctl restart kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl restart kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

echo "Step 9 - End of OpenKAT install script"
4 changes: 2 additions & 2 deletions scripts/installation/openkat-reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fi
pushd /

echo "Stop OpenKAT"
sudo systemctl stop xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl stop xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

echo "Delete XTDB databases"
sudo rm -rf /var/lib/xtdb/*
Expand Down Expand Up @@ -89,6 +89,6 @@ if [[ ${1} != "no_super_user" ]]; then
fi

echo "Start OpenKAT"
sudo systemctl start xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl start xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

popd
2 changes: 1 addition & 1 deletion scripts/installation/openkat-restart.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

echo "Restarting openKAT..."
sudo systemctl restart xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl restart xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
2 changes: 1 addition & 1 deletion scripts/installation/openkat-start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

echo "Starting openKAT..."
sudo systemctl start xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl start xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
2 changes: 1 addition & 1 deletion scripts/installation/openkat-stop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

echo "Stopping openKAT..."
sudo systemctl stop xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl stop xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
2 changes: 1 addition & 1 deletion scripts/installation/openkat-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ sudo -u kat update-katalogus-db
sudo -u kat update-mula-db

echo "Step 7 - Restart OpenKAT"
sudo systemctl restart xtdb-http-multinode kat-rocky kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker
sudo systemctl restart xtdb-http-multinode kat-rocky kat-rocky-worker kat-mula kat-bytes kat-boefjes kat-normalizers kat-katalogus kat-keiko kat-octopoes kat-octopoes-worker

echo "End of OpenKAT update script"

0 comments on commit 9068e7b

Please sign in to comment.