Skip to content

Commit

Permalink
fix(ephemeral): increase max_stack_depth
Browse files Browse the repository at this point in the history
RHINENG-8335
  • Loading branch information
psegedy authored and jdobes committed Feb 20, 2024
1 parent 2529bcf commit 6af693d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conf/reposcan.env
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ SYNC_CVE_MAP=yes
SYNC_CPE=yes
SYNC_OVAL=yes
SYNC_CSAF=yes

PG_MAX_STACK_DEPTH=6144
4 changes: 4 additions & 0 deletions deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ objects:
value: ${{CW_ENABLED}}
- name: INIT_CONTAINER
value: "true"
- name: PG_MAX_STACK_DEPTH
value: ${PG_MAX_STACK_DEPTH}
command:
- /vmaas/entrypoint.sh
- reposcan
Expand Down Expand Up @@ -482,3 +484,5 @@ parameters:
value: "changes.csv"
- name: CSAF_SYNC_ALL_FILES # sync all csaf files, not only those which are changed
value: "false"
- name: PG_MAX_STACK_DEPTH
value: ''
2 changes: 2 additions & 0 deletions vmaas/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def __init__(self):
self.oval_unfixed_eval_enabled = strtobool(os.getenv("OVAL_UNFIXED_EVAL_ENABLED", "TRUE"))
self.prometheus_multiproc_dir = os.getenv("PROMETHEUS_MULTIPROC_DIR", "/tmp/prometheus_multiproc_dir")

self.pg_max_stack_depth = os.getenv("PG_MAX_STACK_DEPTH", "")


# pylint: disable=too-many-instance-attributes
class Config(BaseConfig, metaclass=Singleton):
Expand Down
7 changes: 7 additions & 0 deletions vmaas/reposcan/database/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def init_schema(self):
self._get_db_lock(conn)
LOGGER.info("Empty database, initializing...")
with conn.cursor() as cur:
if cfg.pg_max_stack_depth:
# vmaas.reposcan needs bigger max_stack_depth for ephemeral environment
# increase max_stack_depth when the DB is empty (probably only in ephemeral env)
cur.connection.autocommit = True # autocommit to run queries without transaction
cur.execute(f"ALTER SYSTEM SET max_stack_depth TO {cfg.pg_max_stack_depth}")
cur.execute(f"ALTER DATABASE vmaas SET max_stack_depth TO {cfg.pg_max_stack_depth}")
cur.connection.autocommit = False
with open(USER_CREATE_SQL_PATH, "r", encoding='utf8') as f_user, \
open(DB_CREATE_SQL_PATH, "r", encoding='utf8') as f_db:
cur.execute(f_user.read())
Expand Down

0 comments on commit 6af693d

Please sign in to comment.