Skip to content

Commit

Permalink
chore: upgrade to python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
psegedy committed Dec 5, 2024
1 parent ee774a0 commit cf04be3
Show file tree
Hide file tree
Showing 24 changed files with 479 additions and 500 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/safety.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
python-version: [3.12]
poetry-version: [1.5]
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
python-version: [3.12]
env:
PGPORT: "5433"
steps:
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN curl -o /etc/yum.repos.d/postgresql.repo \

RUN microdnf module disable -y postgresql || :
RUN microdnf install -y --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \
python311 python3.11-pip python3.11-devel libpq-devel gcc which shadow-utils diffutils systemd libicu git-core postgresql pg_repack && \
python312 python3.12-pip python3.12-devel libpq-devel gcc which shadow-utils diffutils systemd libicu git-core postgresql pg_repack && \
microdnf clean all

# missing pg_config, gcc, python3-devel needed for psycopg on aarch64
Expand All @@ -28,10 +28,10 @@ ADD poetry.lock /engine/

ENV LC_ALL=C.utf8
ENV LANG=C.utf8
RUN pip3.11 install --upgrade pip && \
pip3.11 install --upgrade poetry~=1.5
RUN pip3.12 install --upgrade pip && \
pip3.12 install --upgrade poetry~=1.5
RUN poetry export --only main -f requirements.txt --output requirements.txt && \
pip3.11 install -r requirements.txt
pip3.12 install -r requirements.txt
RUN adduser --gid 0 -d /engine --no-create-home insights

# for manager purposes
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN curl -o /etc/yum.repos.d/postgresql.repo \

RUN microdnf module disable -y postgresql || :
RUN microdnf install -y --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \
python311 python3.11-pip python3.11-devel libpq-devel gcc git postgresql-server which findutils diffutils && \
python312 python3.12-pip python3.12-devel libpq-devel gcc git postgresql-server which findutils diffutils && \
microdnf clean all

# missing pg_config, gcc, python3-devel needed for psycopg on aarch64
Expand All @@ -28,10 +28,10 @@ ADD poetry.lock /engine/

ENV LC_ALL=C.utf8
ENV LANG=C.utf8
RUN pip3.11 install --upgrade pip && \
pip3.11 install --upgrade poetry~=1.5
RUN pip3.12 install --upgrade pip && \
pip3.12 install --upgrade poetry~=1.5
RUN poetry export --with dev -f requirements.txt --output requirements.txt && \
pip3.11 install -r requirements.txt
pip3.12 install -r requirements.txt

ADD . /engine

Expand Down
8 changes: 4 additions & 4 deletions common/mqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from aiokafka import AIOKafkaConsumer
from aiokafka import AIOKafkaProducer
from kafka.errors import KafkaError
from kafka.partitioner.default import DefaultPartitioner
from aiokafka.errors import KafkaError
from aiokafka.partitioner import DefaultPartitioner

from common.config import Config
from common.logging import get_logger
Expand Down Expand Up @@ -86,7 +86,7 @@ class MQReader(MQClient):
"""Wrapper around AIOKafka consumer"""

def __init__(self, topic, group_id=CFG.kafka_group_id, bootstrap_servers=CFG.bootstrap_servers, **kwargs):
self.loop = asyncio.get_event_loop()
self.loop = asyncio.get_running_loop()
if isinstance(topic, str):
topic = [topic]
consumer = AIOKafkaConsumer(
Expand Down Expand Up @@ -123,7 +123,7 @@ class MQWriter(MQClient):
"""Wrapper around AIOKafka producer"""

def __init__(self, topic, bootstrap_servers=CFG.bootstrap_servers, **kwargs):
self.loop = asyncio.get_event_loop()
self.loop = asyncio.get_running_loop()
producer = AIOKafkaProducer(
loop=self.loop,
bootstrap_servers=bootstrap_servers,
Expand Down
2 changes: 1 addition & 1 deletion database/upgrade/dbupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ if [[ "$RETVAL" == "0" && "$EXISTING_TABLES" == "0" ]]; then
echo "ALTER USER ve_db_user_notificator WITH PASSWORD '${VE_DB_USER_NOTIFICATOR_PASSWORD:-ve_db_user_notificator_pwd}'" | psql_exec -
echo "ALTER USER cyndi WITH PASSWORD '${CYNDI_DB_ADMIN_PASSWORD:-cyndi_db_admin_pwd}'" | psql_exec -
else
python3.11 -m database.upgrade.upgrade
python3.12 -m database.upgrade.upgrade
fi
2 changes: 1 addition & 1 deletion deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ objects:
- sh
- -c
- >-
python3.11 -m database.upgrade.upgrade
python3.12 -m database.upgrade.upgrade
env:
- name: DB_UPGRADE_SCRIPTS_DIR
value: /engine/database/schema/upgrade_scripts/
Expand Down
20 changes: 10 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#!/bin/sh

public_port () {
python3.11 -c "import app_common_python as a;print(a.LoadedConfig.publicPort or 8000)"
python3.12 -c "import app_common_python as a;print(a.LoadedConfig.publicPort or 8000)"
}

metrics_port () {
python3.11 -c "import app_common_python as a;print(a.LoadedConfig.metricsPort or 9000)"
python3.12 -c "import app_common_python as a;print(a.LoadedConfig.metricsPort or 9000)"
}

cd $(dirname $0)

if [[ ! -z $1 ]]; then
if [[ "$1" == "vmaas-sync" ]]; then
exec python3.11 -m vmaas_sync.vmaas_sync
exec python3.12 -m vmaas_sync.vmaas_sync
elif [[ "$1" == "manager" ]]; then
exec gunicorn -c manager/gunicorn_conf.py -w ${GUNICORN_WORKERS:-4} --bind=0.0.0.0:$(public_port) --bind=0.0.0.0:$(metrics_port) --timeout=60 --limit-request-field_size=65535 manager.main
elif [[ "$1" == "manager-dev" ]]; then
exec gunicorn --reload -c manager/gunicorn_conf.py -w ${GUNICORN_WORKERS:-4} --bind=0.0.0.0:$(public_port) --bind=0.0.0.0:$(metrics_port) --timeout=60 --limit-request-field_size=65535 manager.main
elif [[ "$1" == "manager-admin" ]]; then
exec gunicorn -c manager/gunicorn_conf.py -w ${GUNICORN_WORKERS:-4} --bind=0.0.0.0:$(public_port) --bind=0.0.0.0:$(metrics_port) --timeout=60 --limit-request-field_size=65535 manager.admin
elif [[ "$1" == "taskomatic" ]]; then
exec python3.11 -m taskomatic.taskomatic
exec python3.12 -m taskomatic.taskomatic
elif [[ "$1" == "notificator" ]]; then
exec python3.11 -m notificator.notificator
exec python3.12 -m notificator.notificator
elif [[ "$1" == "exploit-sync" ]]; then
exec python3.11 -m exploit_sync.exploit_sync
exec python3.12 -m exploit_sync.exploit_sync
elif [[ "$1" == "grouper" ]]; then
exec python3.11 -m grouper.grouper
exec python3.12 -m grouper.grouper
elif [[ "$1" == "listener" ]]; then
exec python3.11 -m listener.listener
exec python3.12 -m listener.listener
elif [[ "$1" == "evaluator" ]]; then
exec python3.11 -m evaluator.evaluator
exec python3.12 -m evaluator.evaluator
elif [[ "$1" == "cluster" ]]; then
exec python3.11 -m cluster.cluster
exec python3.12 -m cluster.cluster
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion evaluator/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def main():
"""Main"""
init_logging()
initialize_unleash()
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()

status_app = create_status_app(LOGGER)
_, status_site = create_status_runner(status_app, int(PROMETHEUS_PORT), LOGGER, loop)
Expand Down
2 changes: 1 addition & 1 deletion grouper/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def main():
"""Start service"""
init_logging()

loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
status_app = create_status_app(LOGGER)
_, status_site = create_status_runner(status_app, int(CFG.prometheus_port), LOGGER, loop)
loop.run_until_complete(status_site.start())
Expand Down
2 changes: 1 addition & 1 deletion listener/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async def run(self):
def main():
"""Main"""
init_logging()
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()

status_app = create_status_app(LOGGER)
_, status_site = create_status_runner(status_app, int(PROMETHEUS_PORT), LOGGER, loop)
Expand Down
2 changes: 1 addition & 1 deletion notificator/notificator.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def queue_proc_logger(task):

def main():
"""Main"""
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()

status_app = create_status_app(LOGGER)
_, status_site = create_status_runner(status_app, int(CFG.prometheus_port), LOGGER, loop)
Expand Down
10 changes: 5 additions & 5 deletions platform_mock/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ RUN curl -o /etc/yum.repos.d/postgresql.repo \

RUN microdnf module disable -y postgresql || :
RUN microdnf install -y --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \
python311 python3.11-pip python3.11-devel libpq-devel gcc which java-openjdk-headless shadow-utils tar gzip file vim systemd libicu postgresql && \
python312 python3.12-pip python3.12-devel libpq-devel gcc which java-openjdk-headless shadow-utils tar gzip file vim systemd libicu postgresql && \
microdnf clean all

RUN ln -s -f /usr/bin/python3.11 /usr/bin/python
RUN ln -s -f /usr/bin/python3.12 /usr/bin/python

WORKDIR /platform_mock

Expand All @@ -17,10 +17,10 @@ ADD poetry.lock /platform_mock/

ENV LC_ALL=C.utf8
ENV LANG=C.utf8
RUN pip3.11 install --upgrade pip && \
pip3.11 install --upgrade poetry~=1.5
RUN pip3.12 install --upgrade pip && \
pip3.12 install --upgrade poetry~=1.5
RUN poetry export --with dev -f requirements.txt --output requirements.txt && \
pip3.11 install -r requirements.txt
pip3.12 install -r requirements.txt

RUN cd /platform_mock && \
mkdir kafka && \
Expand Down
2 changes: 1 addition & 1 deletion platform_mock/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ do
done

# run upload mock
exec python3.11 -m platform_mock.platform_mock
exec python3.12 -m platform_mock.platform_mock
6 changes: 3 additions & 3 deletions platform_mock/platform_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import uuid
from datetime import datetime
from datetime import timezone
from distutils.util import strtobool

import uvicorn
from connexion import AsyncApp
Expand All @@ -33,10 +32,11 @@
from common.database_handler import DatabasePoolConnection
from common.logging import get_logger
from common.logging import init_logging
from common.strtobool import strtobool

LOGGER = get_logger(__name__)
STORAGE_PATH = "/tmp/storage"
LOOP = asyncio.get_event_loop()
LOOP = asyncio.new_event_loop()

CFG = Config()

Expand Down Expand Up @@ -393,7 +393,7 @@ def __init__(self):
self.app.add_url_rule("/api/insights/v1/rule/{rule_id}", "rule/{rule_id}", InsightsRulesHandler),
self.app.add_url_rule("/api/v1/exploits", "exploits", ExploitHandler),

config = uvicorn.Config("platform_mock:app.app", port=8000, log_level="info")
config = uvicorn.Config("platform_mock.platform_mock:app.app", port=8000, log_level="info")
self.server = uvicorn.Server(config)


Expand Down
Loading

0 comments on commit cf04be3

Please sign in to comment.