Skip to content

Commit f35ffc8

Browse files
authored
Update Python version to 3.12 (#270)
This commit updates the CPT Dashboard Python version from 3.9 to 3.12. This required switching from the old & crufty Elasticsearch compatible client to the more modern OpenSearch client. While it's plug-in compatible, the older (v7 Elasticsearch / v1 OpenSearch) compatible Elasticsearch client required ancient versions of `pandas` and `numpy` which aren't compatible with Python 3.12. I upgraded the backend base container image from CentOS 9 to CentOS 10 as this comes with Python 3.12 as the default -- however this required locking the `six` package (an indirect dependency) as we're now getting an older `six` RPM package that `poetry` isn't able to replace with the latest. Furthermore, a "poetry update" reveals a (known/reported) problem in `poetry`, which updates to a version of `virtualenv` that poetry itself can't use. There are more places to change the Python version than I'd like, but given the restrictions on GitHub repo variables for actions on pull requests, I decided not to play with centralizing the version in one place. (This was done some time ago for ARCA, which could serve as a template for some later cleanup.) For some reason, the upgrade broke the ilab functional tests, because date range filtering wasn't working the same. This is weird ... but there was a bug in an array slice that apparently didn't affect the behavior before but now does. I added more strict checking as part of debugging, and left it. There are several one-line miscellaneous fixes tossed in here for convenience: 1. I've noticed that the `e2e` front end tests fail when run locally because the container is unable to write to the mounted `coverage` directory. I fixed that with a `:Z` label on the mount. 2. I ported a small tweak to the ArgoCD Applications from my RH CA (which is still in draft), hoping to fix the automatic app update on merge.
1 parent 1d14673 commit f35ffc8

22 files changed

+1235
-1144
lines changed

.github/workflows/backend-check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.9.20"]
18+
python-version: ["3.12"]
1919

2020
steps:
2121
- uses: actions/checkout@v4
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
strategy:
4141
matrix:
42-
python-version: ["3.9.20"]
42+
python-version: ["3.12"]
4343

4444
steps:
4545
- uses: actions/checkout@v4
@@ -69,7 +69,7 @@ jobs:
6969
runs-on: ubuntu-latest
7070
strategy:
7171
matrix:
72-
python-version: ["3.9.20"]
72+
python-version: ["3.12"]
7373

7474
steps:
7575
- uses: actions/checkout@v4

.github/workflows/build-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fetch-depth: 10
1717
- uses: actions/setup-python@v4
1818
with:
19-
python-version: "3.9"
19+
python-version: "3.12"
2020
- uses: Gr1N/setup-poetry@v9
2121
- name: Install dependencies
2222
run: |

.github/workflows/frontend-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- uses: actions/setup-python@v4
2626
with:
27-
python-version: "3.9"
27+
python-version: "3.12"
2828
- uses: Gr1N/setup-poetry@v9
2929
- name: Install dependencies
3030
run: |

.github/workflows/poetry-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v4
1313
with:
14-
python-version: "3.9"
14+
python-version: "3.12"
1515
- uses: Gr1N/setup-poetry@v9
1616
- name: verify poetry instalation
1717
run: poetry --version

.github/workflows/release-build-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fetch-depth: 10
1818
- uses: actions/setup-python@v4
1919
with:
20-
python-version: "3.9"
20+
python-version: "3.12"
2121
- uses: Gr1N/setup-poetry@v9
2222
- name: Install dependencies
2323
run: |

argocd/templates/dashboard-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ spec:
3232
labels:
3333
argocd.argoproj.io/managed-by: openshift-gitops
3434
automated:
35+
enabled: true
3536
prune: true
3637
selfHeal: true
3738
syncOptions:

argocd/templates/dashboard.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ spec:
3232
labels:
3333
argocd.argoproj.io/managed-by: openshift-gitops
3434
automated:
35+
enabled: true
3536
prune: true
3637
selfHeal: true
3738
syncOptions:

backend/app/services/crucible_svc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
from dateutil import rrule
2222
from dateutil.relativedelta import relativedelta
23-
from elasticsearch import AsyncElasticsearch
2423
from fastapi import HTTPException, status
24+
from opensearchpy import AsyncOpenSearch
2525
from pydantic import BaseModel
2626

2727
from app import config
@@ -726,7 +726,7 @@ def __init__(self, configpath: str = "crucible"):
726726
self.auth = (self.user, self.password) if self.user or self.password else None
727727
self.url = self.cfg.get(configpath + ".url")
728728
self.versions = set()
729-
self.elastic = AsyncElasticsearch(
729+
self.elastic = AsyncOpenSearch(
730730
self.url, http_auth=self.auth, verify_certs=False
731731
)
732732
self.logger.info("Initializing CDM service to %s", self.url)

backend/app/services/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from datetime import datetime, timedelta
33
import traceback
44

5-
from elasticsearch import AsyncElasticsearch
65
from fastapi.encoders import jsonable_encoder
6+
from opensearchpy import AsyncOpenSearch
77

88
from app import config
99
import app.api.v1.commons.constants as constants
@@ -39,11 +39,11 @@ def initialize_es(self, config, path, index):
3939
esUser = config.get(path + ".username")
4040
esPass = config.get(path + ".password")
4141
if esUser:
42-
es = AsyncElasticsearch(
42+
es = AsyncOpenSearch(
4343
url, use_ssl=False, verify_certs=False, http_auth=(esUser, esPass)
4444
)
4545
else:
46-
es = AsyncElasticsearch(url, verify_certs=False)
46+
es = AsyncOpenSearch(url, verify_certs=False)
4747
return es, indice, index_prefix
4848

4949
async def post(

backend/backend.containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM quay.io/centos/centos:stream9
1+
FROM quay.io/centos/centos:stream10
22

33
# 0) Configure Poetry and environment for OpenShift non-root execution
44
ENV POETRY_VIRTUALENVS_CREATE=false \
55
HOME=/backend \
66
XDG_CONFIG_HOME=/backend/.config \
77
XDG_CACHE_HOME=/backend/.cache
8-
8+
99
# 1) Install system deps + Poetry globally (root)
1010
# Installing Poetry globally ensures the binary is on /usr/local/bin
1111
# and therefore available in both OpenShift (random UID) and Podman (root) environments

0 commit comments

Comments
 (0)