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

--init exit code is always an error: 4 not 0 #556

Closed
jamesmstone opened this issue Mar 30, 2023 · 3 comments · Fixed by #557
Closed

--init exit code is always an error: 4 not 0 #556

jamesmstone opened this issue Mar 30, 2023 · 3 comments · Fixed by #557
Assignees
Labels
🐞 bug Something isn't working

Comments

@jamesmstone
Copy link

jamesmstone commented Mar 30, 2023

Hi! Thanks for your awesome work on pg_timetable.

I think there is a slight regression in the exit codes introduced in version 5.

Describe the bug

pg timetable no longer exits with a success (0) exit code when run with --init, since version 5, even when it is still creating the schema.

This can cause a problem when scripting the initialisation of a database.

To Reproduce
Steps to reproduce the behaviour:

  1. create a new db
  2. run pgtimetable with --init flag
  3. the exit code for this is an error, however it does init the schema successfully.
#!/usr/bin/env bash

{
  for version in "3" "4.9" "5" "5.1"; do
    docker rm -f postgres || true
    docker run --rm --name postgres -ePOSTGRES_USER=scheduler -e POSTGRES_PASSWORD=mysecretpassword -d postgres
    timeout 90s /usr/bin/env bash -c "until docker exec postgres pg_isready ; do sleep 5 ; done" # wait for db to be ready

    docker run --rm \
      --link "postgres:postgres" \
      cybertecpostgresql/pg_timetable:$version \
      -h postgres -p 5432 -d postgres -u scheduler --password mysecretpassword -c worker001 --init

    echo "$? - exit code for pg_timetable: $version "
  done
} | grep "exit code for pg_timetable"
0 - exit code for pg_timetable: 3 
0 - exit code for pg_timetable: 4.9 
4 - exit code for pg_timetable: 5 
4 - exit code for pg_timetable: 5.1 
@pashagolub pashagolub self-assigned this Mar 31, 2023
@pashagolub pashagolub added the 🐞 bug Something isn't working label Mar 31, 2023
@pashagolub pashagolub linked a pull request Mar 31, 2023 that will close this issue
@pashagolub
Copy link
Collaborator

Thanks a lot for reporting this bug James! Would you be so kind and confirm it's fixed by #557?

Thanks in advance!

pashagolub added a commit that referenced this issue Mar 31, 2023
…s-always-an-error-4-not-0

[-] fix exit code for `--init` command, fixes #556
@gaslitbytech
Copy link

gaslitbytech commented Mar 31, 2023

Seeing that the docker taglatest was published hours ago and adding "latest" to the version test script for loop @jamesmstone provided I can confirm it now passes:

0 - exit code for pg_timetable: latest 

@jamesmstone
Copy link
Author

Thanks Pavlo for your quick fix, yes this fixes the issue. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants