Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker-jans-persistence-loader): exclude external tables when creating indexes #10522

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docker-jans-persistence-loader/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ ARG JANS_CONFIG_API_RESOURCES=jans-config-api/server/src/main/resources

# note that as we're pulling from a monorepo (with multiple project in it)
# we are using partial-clone and sparse-checkout to get the assets
RUN git clone --depth 500 --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \
ARG GIT_CLONE_DEPTH=100
RUN git clone --depth ${GIT_CLONE_DEPTH} --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \
&& cd /tmp/jans \
&& git sparse-checkout init --cone \
&& git checkout ${JANS_SOURCE_VERSION} \
Expand Down Expand Up @@ -53,11 +54,13 @@ RUN cd /tmp/jans \
# Python
# ======

# default pip timeout
ARG PIP_TIMEOUT=15
COPY requirements.txt /app/requirements.txt
RUN mv /usr/lib/python3.12/EXTERNALLY-MANAGED /usr/lib/python3.12/EXTERNALLY-MANAGED.disabled \
&& python3 -m ensurepip \
&& pip3 install --no-cache-dir -U pip wheel setuptools \
&& pip3 install --no-cache-dir -r /app/requirements.txt \
&& pip3 install --no-cache-dir -U pip wheel setuptools --timeout ${PIP_TIMEOUT} \
&& pip3 install --no-cache-dir -r /app/requirements.txt --timeout ${PIP_TIMEOUT} \
&& pip3 uninstall -y pip wheel

# =======
Expand Down
14 changes: 9 additions & 5 deletions docker-jans-persistence-loader/scripts/sql_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,17 @@ def create_pgsql_indexes(self, table_name: str, column_mapping: dict):
self.client.create_index(query)

def create_indexes(self):
for table_name, column_mapping in self.client.get_table_mapping().items():
# exclude tables that created externally https://github.com/JanssenProject/jans/issues/10512
table_mapping = {
k: v for k, v in self.client.get_table_mapping().items()
if k in self.table_mapping_from_schema()
}

for table_name, column_mapping in table_mapping.items():
if self.client.dialect == "pgsql":
index_func = self.create_pgsql_indexes
self.create_pgsql_indexes(table_name, column_mapping)
else:
index_func = self.create_mysql_indexes
# run the callback
index_func(table_name, column_mapping)
self.create_mysql_indexes(table_name, column_mapping)

def create_unique_indexes(self):
for table_name, column in [
Expand Down
Loading