Skip to content

feat: switch to pgedge-patroni for systemd#372

Merged
jason-lynch merged 1 commit intomainfrom
feat/switch-systemd-to-pgedge-patroni
May 1, 2026
Merged

feat: switch to pgedge-patroni for systemd#372
jason-lynch merged 1 commit intomainfrom
feat/switch-systemd-to-pgedge-patroni

Conversation

@jason-lynch
Copy link
Copy Markdown
Member

Summary

We now distribute Patroni from the pgEdge Enterprise Postgres repository. This commit switches from using pip to install Patroni to using pgEdge's Patroni package.

Our package does not include the jsonlogger packages, so I also needed to switch to plain log output.

It's still possible for end users to use a different Patroni installation by changing the patroni_path configuration setting on the host.

Changes

  • Change the dev-lima environment to install the pgedge-patroni package.
  • Change the default systemd.patroni_path to /usr/bin/patroni
  • Update the patroni path in our tests to look more realistic

Testing

# teardown the dev-lima environment if you already have it setup
make dev-lima-teardown

# deploy the dev-lima environment
make dev-lima-deploy

# start the control plane in one terminal
make dev-lima-run

# in another terminal
# switch to the dev-lima environment
use-dev-lima

# create a database
cp1-req create-database <<EOF | cp-follow-task
{
  "id": "storefront",
  "spec": {
    "database_name": "storefront",
    "database_users": [
      {
        "username": "admin",
        "password": "password",
        "db_owner": true,
        "attributes": ["SUPERUSER", "LOGIN"]
      }
    ],
    "port": 0,
    "patroni_port": 0,
    "nodes": [
      { "name": "n1", "host_ids": ["host-1"] }
    ]
  }
}
EOF

Notes for Reviewers

  • I'm updating the systemd installation doc in a separate PR.
  • The swarm package isn't the orchestrator/common package yet, so those changes only affect systemd right now.

We now distribute Patroni from the pgEdge Enterprise Postgres
repository. This commit switches away from using `pip` to install
Patroni and uses pgEdge's patroni package instead.

Our package does not include the jsonlogger packages, so I also needed
to switch to `plain` log output.

It's still possible for end users to use a different Patroni
installation by changing the `patroni_path` configuration setting on the
host.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 67b91fe5-0e3a-4533-9e3f-ced3116f9f60

📥 Commits

Reviewing files that changed from the base of the PR and between 88d83e3 and f354b20.

📒 Files selected for processing (11)
  • lima/roles/install_prerequisites/tasks/main.yaml
  • server/internal/config/config.go
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/enable_fast_basebackup.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/minimal_systemd.yaml
  • server/internal/orchestrator/common/patroni_config_generator.go
  • server/internal/orchestrator/common/patroni_config_generator_test.go
  • server/internal/orchestrator/systemd/golden_test/TestUnitOptions/PatroniUnitOptions/cpu_limit.service
  • server/internal/orchestrator/systemd/golden_test/TestUnitOptions/PatroniUnitOptions/fractional_cpu_limit.service
  • server/internal/orchestrator/systemd/golden_test/TestUnitOptions/PatroniUnitOptions/memory_max.service
  • server/internal/orchestrator/systemd/golden_test/TestUnitOptions/PatroniUnitOptions/minimal.service
  • server/internal/orchestrator/systemd/unit_options_test.go

📝 Walkthrough

Walkthrough

The changes relocate the Patroni binary path from /usr/local/bin/patroni to /usr/bin/patroni, shift Patroni installation from pip-based to system package provisioning, add configurable logging type support to the Patroni config generator, and update test fixtures for PostgreSQL 18 versioned directory paths and plain-text logging format.

Changes

Cohort / File(s) Summary
Patroni Installation Method
lima/roles/install_prerequisites/tasks/main.yaml
Removes Python tooling and pip-based Patroni installation; replaces with pgedge-patroni system package dependency.
Patroni Binary Path Relocation
server/internal/config/config.go, server/internal/orchestrator/systemd/unit_options_test.go
Updates PatroniPath configuration default from /usr/local/bin/patroni to /usr/bin/patroni.
Patroni Config Generator Enhancements
server/internal/orchestrator/common/patroni_config_generator.go
Adds LogType field to PatroniConfigGenerator and PatroniConfigGeneratorOptions; updates log() method to derive log type from configuration instead of hardcoding JSON.
Patroni Config Generator Test Updates
server/internal/orchestrator/common/patroni_config_generator_test.go
Updates test configurations with LogType: patroni.LogTypeJson; adjusts PatroniPath and PostgreSQL data directory paths to version 18 locations.
Systemd Service Unit Updates
server/internal/orchestrator/systemd/golden_test/TestUnitOptions/PatroniUnitOptions/cpu_limit.service, fractional_cpu_limit.service, memory_max.service, minimal.service
Updates ExecStart directives in all Patroni systemd service units to reference /usr/bin/patroni instead of /usr/local/bin/patroni.
Golden Test Fixtures
server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/enable_fast_basebackup.yaml, minimal_systemd.yaml
Updates logging format from JSON to plain text; adjusts TLS certificate/key and data directory paths to PostgreSQL 18 versioned location /var/lib/pgsql/18/.

Poem

🐰 A rabbit hops through paths anew,
From /usr/local to /usr/bin — who knew?
No more pip wheels, just packages clean,
Logs in plain text, not JSON's sheen!
Version 18 paths shine bright,
Our Patroni now feels just right! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: switching to pgedge-patroni for systemd installation instead of pip-based installation.
Description check ✅ Passed The description follows the template structure with Summary, Changes, Testing, and Notes for Reviewers sections. All critical information is present and well-documented.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/switch-systemd-to-pgedge-patroni

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jason-lynch jason-lynch merged commit 5a9d75f into main May 1, 2026
3 checks passed
@jason-lynch jason-lynch deleted the feat/switch-systemd-to-pgedge-patroni branch May 1, 2026 17:20
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.

2 participants