Skip to content

Use ROX_SCANNER_DB_INIT env var in ScannerDB initContainer #960

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

Merged
merged 3 commits into from
Oct 5, 2022
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
4 changes: 2 additions & 2 deletions chart/templates/db-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ spec:
env:
- name: POSTGRES_PASSWORD_FILE
value: "/run/secrets/stackrox.io/secrets/password"
command: ["docker-entrypoint.sh"]
args: ["init", "postgres", "-c", "config_file=/etc/postgresql.conf"]
- name: ROX_SCANNER_DB_INIT
value: "true"
resources:
limits:
cpu: 2
Expand Down
11 changes: 2 additions & 9 deletions image/db/rhel/scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,9 @@ _main() {
set -- postgres "$@"
fi

### STACKROX MODIFIED - Declare variable useful to determine if we want to initialize the DB.
local init
if [ "$1" = 'init' ]; then
init='true'
shift
fi

if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then
### STACKROX MODIFIED - If we are initializing, then ensure we start from scratch.
if [ -n "$init" ]; then
if [ -n "$ROX_SCANNER_DB_INIT" ]; then
echo
echo 'Initializing... Clearing any previous data from directories'
echo
Expand All @@ -338,7 +331,7 @@ _main() {

### STACKROX MODIFIED - Sanity check the database does not exist
### upon initialization.
if [ -n "$init" ] && [ -n "$DATABASE_ALREADY_EXISTS" ]; then
if [ -n "$ROX_SCANNER_DB_INIT" ] && [ -n "$DATABASE_ALREADY_EXISTS" ]; then
echo
echo 'PostgreSQL Database appears to already exist upon initialization; Exiting with error...'
echo
Expand Down