Fix bareos_tasks plugin for pgsql#1641
Conversation
There was a problem hiding this comment.
Thank you for your contribution. I've taken your PR as trigger to create a systemtest for this plugin. I published it to https://github.com/joergsteffens/bareos/tree/dev/joergs/master/tasks_pgsql
If you don't mind, I would add it to this PR.
| if stderrtext: | ||
| self.stderr_buffer.write(stderrtext) | ||
| else: | ||
| break |
There was a problem hiding this comment.
Can you describe, when the previous version failed?
There was a problem hiding this comment.
The old code failed on some backups. The error we had was that it was operating on a nonetype. And effectively the "stderrtext" would be empty in certain cases.
| def __init__(self, psql=None, pg_user=None): | ||
| self.run_as_user = pg_user | ||
| psql_options = 'postgres --expanded --no-align' | ||
| psql_options = '--expanded --no-align --no-psqlrc' |
There was a problem hiding this comment.
In my test, specifying a database is required for the psql command. Therefore the default database postgres is given as command. Does it work otherwise in our environment?
There was a problem hiding this comment.
It worked perfectly without it, the original code didn't have it either.
The --no-psqlrc is definitely an enhancement (which I assume cannot cause any harm), since we have a global psqlrc which breaks the backups otherwise
There was a problem hiding this comment.
PS: if you want to specify the database, I would use -d postgres explicitly, instead of specifying without -d. But I'm not sure why we'd need this in our case. Also if we'd like to connect as another user, in theory we could have no access to postgres db
Running this plugin now on +- 10 machines with postgresql 13 to 16 and all work fine as-is.
There was a problem hiding this comment.
Check the docs: https://www.postgresql.org/docs/15/libpq-connect.html
So this is really default behavior to use the same db name as the connecting user! :)
There was a problem hiding this comment.
I see.
I've now added my commits to this PR (systemtest and a bit of cleanup in the plugin).
I'd like to merge this PR. For this, you should squash your commits into one (git rebase -i origin/master ...)
Also the commit comment should be something like:
contrib bareos_tasks.pgsql: fixes
Fix reading stderr and encoding issues.
Also you might want to add your name to the AUTHORS file.
There was a problem hiding this comment.
Do I still need to do something? If it could be avoided, it would be better since I'm working on a different project and I'm not extremely acquainted with git either :)
|
Replaced by #1659, as I failed to push to this PR. |

Thank you for contributing to the Bareos Project!
**The pgsql plugin from bareos_tasks is currently not working at all. There were a few errors which are now fixed and the plugin was testing and working properly on a few test machines
Please check
If you have any questions or problems, please give a comment in the PR.
Helpful documentation and best practices
Checklist for the reviewer of the PR (will be processed by the Bareos team)
Make sure you check/merge the PR using
devtools/pr-toolto have some simple automated checks run and a proper changelog record added.General
Source code quality
Tests