Skip to content

Commit 6c10507

Browse files
authored
Back off CA validation on OpenSearch (#275)
This problem turned out to be a bit more difficult than I'd hoped, since we build our deployment containers on GitHub Actions with external runners which can't reach the internal Red Hat CA URL. Ultimately the solution would have to be grabbing and installing the CA bundle at container startup (e.g., in the entrypoint); but for now I'm going to declare (temporary) defeat and restore the `verify_certs=False`.
1 parent 9dfc933 commit 6c10507

File tree

9 files changed

+17
-27
lines changed

9 files changed

+17
-27
lines changed

.github/workflows/build-push.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ jobs:
5454
with:
5555
image: backend
5656
context: backend
57-
build-args: |
58-
CA_CERT_PATH=${{ secrets.CA_CERT_PATH}}
5957
tags: latest ${{ github.sha }}
6058
containerfiles: |
6159
./backend/backend.containerfile

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ jobs:
5555
with:
5656
image: backend
5757
context: backend
58-
build-args: |
59-
CA_CERT_PATH=${{ secrets.CA_CERT_PATH}}
6058
tags: prod ${{ github.sha }}
6159
containerfiles: |
6260
./backend/backend.containerfile

backend/app/services/crucible_svc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,9 @@ 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 = AsyncOpenSearch(self.url, http_auth=self.auth)
729+
self.elastic = AsyncOpenSearch(
730+
self.url, verify_certs=False, http_auth=self.auth
731+
)
730732
self.logger.info("Initializing CDM service to %s", self.url)
731733

732734
async def detect_versions(self):

backend/app/services/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def initialize_es(self, config, path, index):
3939
esUser = config.get(path + ".username")
4040
esPass = config.get(path + ".password")
4141
if esUser:
42-
es = AsyncOpenSearch(url, http_auth=(esUser, esPass))
42+
es = AsyncOpenSearch(url, verify_certs=False, http_auth=(esUser, esPass))
4343
else:
44-
es = AsyncOpenSearch(url)
44+
es = AsyncOpenSearch(url, verify_certs=False)
4545
return es, indice, index_prefix
4646

4747
async def post(

backend/backend.containerfile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ ENV POETRY_VIRTUALENVS_CREATE=false \
66
XDG_CONFIG_HOME=/backend/.config \
77
XDG_CACHE_HOME=/backend/.cache
88

9-
# We just want a "safe" file we can always copy with innocuous content if no
10-
# CA is specified.
11-
ARG CA_CERT_PATH=""
12-
13-
# Add a CA certificate to the container trust store
14-
ADD ${CA_CERT_PATH} /etc/pki/ca-trust/source/anchors/
15-
RUN update-ca-trust
16-
179
# 1) Install system deps + Poetry globally (root)
1810
# Installing Poetry globally ensures the binary is on /usr/local/bin
1911
# and therefore available in both OpenShift (random UID) and Podman (root) environments

backend/tests/unit/test_search.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def test_initialize_es_with_auth(self, mock_es, mock_config_full):
135135
)
136136

137137
mock_es.assert_called_with(
138-
"http://localhost:9200", http_auth=("testuser", "testpass")
138+
"http://localhost:9200",
139+
verify_certs=False,
140+
http_auth=("testuser", "testpass"),
139141
)
140142
assert indice == "test-index"
141143
assert prefix == "test-"
@@ -149,7 +151,7 @@ def test_initialize_es_without_auth(self, mock_es, mock_config_no_auth):
149151
mock_config_no_auth, "elasticsearch", "custom-index"
150152
)
151153

152-
mock_es.assert_called_with("http://localhost:9200")
154+
mock_es.assert_called_with("http://localhost:9200", verify_certs=False)
153155
assert indice == "custom-index"
154156
assert prefix == ""
155157

run-container.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ BRANCH="$(git rev-parse --show-toplevel)"
1111
BACKEND="${BRANCH}/backend"
1212
FRONTEND="${BRANCH}/frontend"
1313
CPT_CONFIG=${CPT_CONFIG:-"${BACKEND}/ocpperf.toml"}
14+
if [ ! -f "${CPT_CONFIG}" ]; then
15+
echo "Error: ${CPT_CONFIG} not found" >&2
16+
echo "Please update the ${CPT_CONFIG} file to meet your needs." >&2
17+
exit 1
18+
fi
1419

1520
export CONTAINERS=()
1621

@@ -26,16 +31,9 @@ cleanup () {
2631
fi
2732
}
2833

29-
if [ -z "${CA_CERT_PATH}" ]; then
30-
echo "CA_CERT_PATH is not set"
31-
arg=""
32-
else
33-
arg="--build-arg CA_CERT_PATH=${CA_CERT_PATH}"
34-
fi
35-
3634
echo "Creating version"
3735
( cd ${BACKEND}; poetry install ; poetry run scripts/version.py )
38-
podman build -f backend.containerfile ${arg} --tag backend "${BACKEND}"
36+
podman build -f backend.containerfile --tag backend "${BACKEND}"
3937
echo "Starting backend container"
4038
podman run -d --name="backend" -p 127.0.0.1:8000:8000 -v "${CPT_CONFIG}:/backend/ocpperf.toml:Z" localhost/backend
4139
CONTAINERS=( "backend" )

run-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ FRONTEND=${TOP}/frontend
2222
CPT_CONFIG=${CPT_CONFIG:-"${BACKEND}/ocpperf.toml"}
2323
if [ ! -f "${CPT_CONFIG}" ]; then
2424
echo "Error: ${CPT_CONFIG} not found" >&2
25-
echo "Please update the backend/ocpperf.toml file to meet your needs." >&2
25+
echo "Please update the ${CPT_CONFIG} file to meet your needs." >&2
2626
exit 1
2727
fi
2828

testing/pod_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ podman pod create --name=${POD_NAME} ${PUBLISH}
6363

6464
echo "Creating version"
6565
( cd ${BACKEND}; poetry install; poetry install; poetry run scripts/version.py )
66-
podman build -f backend.containerfile --build-arg CA_CERT_PATH="" --tag backend "${BACKEND}"
66+
podman build -f backend.containerfile --tag backend "${BACKEND}"
6767
podman build -f frontend.containerfile --tag frontend "${FRONTEND}"
6868
podman build -f ${TESTING}/functional.containerfile --tag functional "${BRANCH}"
6969

0 commit comments

Comments
 (0)