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

DPE 71 Patroni resource install #4

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Mar 29, 2022

Issue

In short this PR partially address JIRA ticket DPE-71. The remaining implementation is split in three separate PRs to make the review easier.

In long:

  • In order to enable automatic failover and replication through Patroni in a PostgreSQL deployment we need to change the way PostgreSQL is bootstraped/started (Patroni should be started; it'll start PostgreSQL later).
  • Patroni is released as a Python package, which should be installed by the charm to later be started.

Solution

  • Enable the human operator to inform a resource containing Patroni Python package when deploying.
  • Installing this resource together with PostgreSQL database in the charm

Context

  • Additional Patroni dependencies (like python-dev and psycopg2) will be changed to be installed as offline packages in a future PR.

Testing

  • Unit tests
  • Some manual testing to ensure the charm still gets to the desired state
  • Update of the tox.ini file and the deploy integration test to download and add Patroni as a resource (the successful install of the resource will be better tested in the next PR, where the bootstrap process is switched to use Patroni)

Release Notes

  • Add Patroni as a resource
  • Add pip as a charm-python-packages part for bionic series
  • Install Patroni dependencies (python-dev and psycopg2)
  • Implement logic to install Patroni Python package
  • Update apt update unit test matching the implementation of the test_install_pip_packages unit test

@marceloneppel marceloneppel force-pushed the DPE-71-patroni-resource-install branch from db46588 to cd8f838 Compare March 29, 2022 14:35
@marceloneppel marceloneppel force-pushed the DPE-71-patroni-resource-install branch from cd8f838 to 6f0ef9e Compare March 29, 2022 14:39
@marceloneppel marceloneppel marked this pull request as ready for review March 29, 2022 14:56
Copy link
Member

@jnsgruk jnsgruk left a comment

Choose a reason for hiding this comment

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

Overall looking good, thanks Marcelo!

@@ -73,4 +73,10 @@ deps =
psycopg2-binary
-r{toxinidir}/requirements.txt
commands =
# Download patroni resource to use in the charm deployment.
sh -c 'stat patroni.tar.gz > /dev/null 2>&1 || curl "https://github.com/zalando/patroni/archive/refs/tags/v2.1.3.tar.gz" -L -s > patroni.tar.gz'
Copy link
Member

Choose a reason for hiding this comment

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

Could this be some sort of fixture, or downloaded in the pytest code using urllib then cleaned up after the test?

The benefit here, is that once you have an uploaded version on chamrhub, you can fetch the resource straight from Charmhub using the API and get a bit more certainty in the test? (Perhaps a future PR?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it can be, Jon. Nice suggestion! I'll create a new PR to change this that and upload the resource to Charmhub to have this improved flow of testing with the resource. I created an issue to remind about it.

Copy link
Contributor

@MiaAltieri MiaAltieri left a comment

Choose a reason for hiding this comment

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

Great stuff! Amazing PR description and some super thorough commenting. Also thanks for making the PR into two chunks, this is super manageable.

Just have one concern about error handling in install, feel free to PM me if you want to chat about it 😄 Other than that, it looks great!

src/charm.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
tests/unit/test_charm.py Show resolved Hide resolved
Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

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

LGTM, considering Mia's comments

@marceloneppel marceloneppel requested a review from MiaAltieri April 5, 2022 19:32
Copy link
Contributor

@MiaAltieri MiaAltieri left a comment

Choose a reason for hiding this comment

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

Looks great to me! I like how you handled those cases on failure to install. Great work.

Made some suggestions to the tests but if you disagree then feel free to ignore my suggestions :)

tests/unit/test_charm.py Show resolved Hide resolved
tests/unit/test_charm.py Show resolved Hide resolved
@marceloneppel marceloneppel force-pushed the DPE-71-patroni-resource-install branch from b7b28b7 to fac4ee2 Compare April 6, 2022 13:26
@marceloneppel marceloneppel merged commit 7775f15 into main Apr 6, 2022
@marceloneppel marceloneppel deleted the DPE-71-patroni-resource-install branch April 6, 2022 13:27
BON4 pushed a commit to BON4/postgresql-operator that referenced this pull request Apr 23, 2024
* Add Patroni resource

* Correctly handle calls from on install hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants