Skip to content

feat: add orchestrator/common package#293

Merged
jason-lynch merged 1 commit intomainfrom
feat/PLAT-417/orchestrator-common-resources
Mar 31, 2026
Merged

feat: add orchestrator/common package#293
jason-lynch merged 1 commit intomainfrom
feat/PLAT-417/orchestrator-common-resources

Conversation

@jason-lynch
Copy link
Copy Markdown
Member

Summary

Adds a package with common resources that can be shared between more than one orchestrator implementation. This is conceptually distinct from the common resources in the database package, which are shared across all current and future orchestrator implementations.

Testing

There are no user-facing functionality changes in this PR.

PLAT-417

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd7f8051-c255-4143-ae26-9c9d13ae425a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request introduces a comprehensive orchestration framework for managing Patroni/PostgreSQL clusters with etcd integration. It adds resource types for credentials, certificates, and configuration management, implements Patroni config generation with multiple deployment strategies, and registers these resources globally via a new common module.

Changes

Cohort / File(s) Summary
Registry & Command Setup
server/cmd/root.go, server/internal/database/orchestrator.go
Registers new common orchestrator resource types via common.RegisterResourceTypes() during initialization, and adds ExecuteInstanceCommand method to the Orchestrator interface for executing arbitrary instance commands.
Etcd Credentials Resource
server/internal/orchestrator/common/etcd_creds.go
Introduces EtcdCreds resource type with lifecycle methods to manage etcd user credentials, client certificates, and CA certificates on disk with proper ownership and permissions.
PostgreSQL Certificates Resource
server/internal/orchestrator/common/postgres_certs.go
Adds PostgresCerts resource for managing PostgreSQL server and role certificates (superuser, replication) with certificate generation via injected service and cleanup on deletion.
Backup & Restore Configuration Resources
server/internal/orchestrator/common/pgbackrest_config.go, server/internal/orchestrator/common/pgbackrest_stanza.go
Implements PgBackRestConfig and PgBackRestStanza resources for managing pgBackRest configuration files and stanza initialization/validation with backup/restore type variants.
Patroni Cluster & Member Resources
server/internal/orchestrator/common/patroni_cluster.go, server/internal/orchestrator/common/patroni_member.go
Defines PatroniCluster and PatroniMember resources with etcd-backed lifecycle methods for cluster namespace and member registration/cleanup in the distributed configuration store.
Patroni Configuration Generation
server/internal/orchestrator/common/patroni_config_generator.go, server/internal/orchestrator/common/patroni_config.go
Provides PatroniConfigGenerator for building comprehensive Patroni configs with support for fast basebackup, restore workflows, and custom PostgreSQL parameters; PatroniConfig resource manages config file lifecycle.
Patroni Configuration Golden Tests
server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/*.yaml, server/internal/orchestrator/common/patroni_config_generator_test.go, server/internal/orchestrator/common/main_test.go
Adds extensive golden-file test suite covering minimal swarm/systemd configurations, backup/restore workflows, fast basebackup, and in-place restore scenarios with golden YAML outputs for verification.
Service Configuration Resources
server/internal/orchestrator/common/pg_service_conf.go
Introduces PgServiceConf resource for generating and managing pg\_service.conf file with DSN entries for all cluster nodes.
Path & Command Utilities
server/internal/orchestrator/common/paths.go, server/internal/orchestrator/common/paths_test.go
Adds InstancePaths and Paths types for managing directory structure and generating pgBackRest/data movement commands with intelligent target-action injection for restore workflows.
Resource Registration
server/internal/orchestrator/common/resources.go
Central registration function that wires all common resource types (EtcdCreds, PostgresCerts, PgBackRestConfig/Stanza, PatroniCluster/Member, PgServiceConf) into the resource framework.
Etcd Host Discovery
server/internal/patroni/utils.go
Adds EtcdHosts utility function to extract client host addresses from etcd cluster member list with URL parsing and error wrapping.
PgBackRest Port Configuration
server/internal/pgbackrest/config.go
Extends ConfigOptions with Port field and writes pg1\-port to pgBackRest config when Port is specified.
PostgreSQL GUC & Service Utilities
server/internal/postgres/gucs.go, server/internal/postgres/pg_service_conf.go
Simplifies SnowflakeLolorGUCs signature (removes error return), adds PgServiceConf type for INI-style service configuration generation with sorted section output.
Swarm Orchestrator Implementation
server/internal/orchestrator/swarm/orchestrator.go, server/internal/orchestrator/swarm/patroni_config.go
Implements ExecuteInstanceCommand wrapper for container execution; updates patroni config to use non-error SnowflakeLolorGUCs signature.

Poem

🐰 Hop, hop, resources hop!
Etcd creds and certs won't stop,
Patroni configs bloom so fine,
With TLS, backups, all align!
From swarm to systemd we dance with glee,
Building clusters wild and free! 🌿

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It lacks required sections including Changes, Testing (beyond a statement about no user-facing changes), and Checklist items. The description does not follow the provided template structure. Complete the PR description by adding missing sections: expand Changes with a bulleted list of key additions, provide explicit testing instructions (e.g., 'go test ./...'), and mark all applicable Checklist items.
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 (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add orchestrator/common package' is clear, concise, and directly summarizes the main change: adding a new package for shared orchestrator resources.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/PLAT-417/orchestrator-common-resources

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

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

@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 298c58f to 887b1a8 Compare March 9, 2026 22:37
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 2 times, most recently from 9bfda29 to 3bd613f Compare March 10, 2026 13:10
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 887b1a8 to daeb238 Compare March 10, 2026 13:10
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 2 times, most recently from 2000707 to 321ebff Compare March 10, 2026 14:33
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 20b19ea to b768409 Compare March 10, 2026 14:33
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 3 times, most recently from 7213a0b to fbd7177 Compare March 10, 2026 21:01
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from e47f053 to 26aa05d Compare March 11, 2026 12:58
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from fbd7177 to 818b6cd Compare March 11, 2026 12:58
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 26aa05d to a856583 Compare March 11, 2026 13:25
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 818b6cd to db06d7c Compare March 11, 2026 13:25
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from a856583 to 57a6663 Compare March 11, 2026 13:43
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from db06d7c to 94c2dbe Compare March 11, 2026 13:43
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 57a6663 to e656f49 Compare March 11, 2026 13:49
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 94c2dbe to 1de4ace Compare March 11, 2026 13:49
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from e656f49 to 4e0f475 Compare March 12, 2026 19:28
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 1de4ace to 187c000 Compare March 12, 2026 19:28
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 4e0f475 to 3b3cfbb Compare March 12, 2026 21:17
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 187c000 to a6f44f6 Compare March 12, 2026 21:17
@jason-lynch
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 42e1c4c to d62db24 Compare March 23, 2026 21:21
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 2f99484 to f0153f4 Compare March 23, 2026 21:21
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from d62db24 to 761cc61 Compare March 23, 2026 21:24
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 3 times, most recently from 712408d to c8dcd98 Compare March 23, 2026 21:36
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 38ca3e9 to 21eafe2 Compare March 23, 2026 21:52
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from c8dcd98 to 92554b8 Compare March 23, 2026 21:52
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 21eafe2 to cb06a2c Compare March 23, 2026 23:20
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 92554b8 to b2ab571 Compare March 23, 2026 23:20
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from cb06a2c to 019f9bb Compare March 23, 2026 23:33
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from b2ab571 to c52c641 Compare March 23, 2026 23:33
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from 019f9bb to cc66bd1 Compare March 23, 2026 23:36
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 2 times, most recently from f32affe to ecb25d0 Compare March 24, 2026 00:15
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch 2 times, most recently from 0777377 to ce0a342 Compare March 24, 2026 13:19
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch 2 times, most recently from 755fb27 to 2379e46 Compare March 24, 2026 18:15
@jason-lynch jason-lynch requested a review from tsivaprasad March 30, 2026 15:35
Type: hba.EntryTypeHost,
Database: "all",
User: "pgedge,patroni_replicator",
Address: "::0/0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is Address: "::0/0" correct, or should it be Address: "::/0"? It looks like it might be a typo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! I think they're equivalent, but you're right that ::/0 seems more common. I'll double-check that Postgres is OK with the ::/0 form and update it if so.

@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from c85cf22 to bed8c2f Compare March 31, 2026 16:43
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 2379e46 to 8ce1172 Compare March 31, 2026 16:43
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Mar 31, 2026

Up to standards ✅

🟢 Issues 9 medium

Results:
9 new issues

Category Results
Complexity 9 medium

View in Codacy

🟢 Metrics 261 complexity . 128 duplication

Metric Results
Complexity 261
Duplication 128

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Adds a package with common resources that can be shared between more
than one orchestrator implementation. This is conceptually distinct from
the common resources in the `database` package, which are shared across
all current and future orchestrator implementations.

PLAT-417
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/postgres-database-resource branch from bed8c2f to 9c5c0ec Compare March 31, 2026 16:51
@jason-lynch jason-lynch force-pushed the feat/PLAT-417/orchestrator-common-resources branch from 8ce1172 to 2058c1f Compare March 31, 2026 16:51
Base automatically changed from feat/PLAT-417/postgres-database-resource to main March 31, 2026 17:33
@jason-lynch jason-lynch merged commit 27090e7 into main Mar 31, 2026
3 checks passed
@jason-lynch jason-lynch deleted the feat/PLAT-417/orchestrator-common-resources branch March 31, 2026 17:34
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