Skip to content

Commit

Permalink
Merge pull request #187 from kobotoolbox/improve-replication-password…
Browse files Browse the repository at this point in the history
…-message

Improve error message when PostgreSQL replication password contains unsupported message
  • Loading branch information
jnm authored May 11, 2022
2 parents 6f84380 + b321a40 commit a055eea
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions helpers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,27 +616,35 @@ def validate_passwords(self):
},
}
errors = []
psql_replication = passwords.pop('PostgreSQL replication')
for label, config_ in passwords.items():
if not re.match(config_['pattern'], config_['password']):
errors.append(label)
CLI.colored_print(
f'{label} password contains unsupported characters.',
CLI.COLOR_WARNING
CLI.COLOR_ERROR
)
if errors:
CLI.colored_print(
'You should run `python run.py --setup` to update.',
CLI.COLOR_WARNING
)

# PostgreSQL replication password must be handled separately because
# it is set in PostgreSQL on the first launch and nothing is done
# afterwards in subsequent starts to update it if it has changed.
if not re.match(
psql_replication['pattern'], psql_replication['password']
):
CLI.colored_print(
'PostgreSQL replication password contains unsupported characters.',
CLI.COLOR_ERROR
)
# PostgreSQL replication password is set in PostgreSQL on the first
# launch and nothing is run afterwards in subsequent starts to update
# it if it has changed.
if 'PostgreSQL replication' in errors:
CLI.colored_print(
'PostgreSQL replication password must be changed manually\n'
'in `kobo-install/.run.conf` and PostgreSQL itself.',
CLI.COLOR_WARNING
)
CLI.colored_print(
'It must be changed manually in `kobo-install/.run.conf` '
'(and PostgreSQL itself if you use replication).',
CLI.COLOR_WARNING
)

def write_config(self):
"""
Expand Down

0 comments on commit a055eea

Please sign in to comment.