Skip to content

Commit

Permalink
fix(docker-jans-persistence-loader): exclude external tables when cre…
Browse files Browse the repository at this point in the history
…ating indexes (#10522)

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

Signed-off-by: iromli <isman.firmansyah@gmail.com>

* build(cloud-native): add configurable build args

* build(cloud-native): remove unnecessary pip option

Signed-off-by: iromli <isman.firmansyah@gmail.com>

---------

Signed-off-by: iromli <isman.firmansyah@gmail.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
  • Loading branch information
iromli and moabu authored Dec 31, 2024
1 parent c79a418 commit 9610bc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
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

0 comments on commit 9610bc1

Please # to comment.