Skip to content

Fix bareos_tasks plugin for pgsql#1641

Closed
HOSTED-POWER wants to merge 6 commits intobareos:masterfrom
HOSTED-POWER:master
Closed

Fix bareos_tasks plugin for pgsql#1641
HOSTED-POWER wants to merge 6 commits intobareos:masterfrom
HOSTED-POWER:master

Conversation

@HOSTED-POWER
Copy link

@HOSTED-POWER HOSTED-POWER commented Dec 20, 2023

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

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

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-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@bruno-at-bareos bruno-at-bareos changed the title Fix pgsql plugin Fix bareos_tasks plugin for pgsql Dec 21, 2023
@arogge arogge requested a review from joergsteffens December 21, 2023 11:20
Copy link
Member

@joergsteffens joergsteffens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe, when the previous version failed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

@HOSTED-POWER HOSTED-POWER Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the docs: https://www.postgresql.org/docs/15/libpq-connect.html

image

So this is really default behavior to use the same db name as the connecting user! :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

@joergsteffens
Copy link
Member

Replaced by #1659, as I failed to push to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants