-
Notifications
You must be signed in to change notification settings - Fork 2
feat: use common resources in swarm #406
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
Merged
jason-lynch
merged 9 commits into
main
from
fix/PLAT-610/update-global-patroni-params-swarm
Jun 16, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2f26412
feat: use common resources in swarm
jason-lynch c2b6843
feat: add pgbackrest config to patroni config dependencies
jason-lynch da55d25
feat: add database id arg to state migrations
jason-lynch 3e8ef36
test: shared golden instance for migration tests
jason-lynch 8cc7fe4
feat: v1.2.0 state migration
jason-lynch bcf62e3
feat: remove dynamic config update from instance resource
jason-lynch 6ba8698
test: add heartbeat utility for e2es
jason-lynch e5f6f11
refactor: container port constants
jason-lynch 232e86b
docs: update global params changelog entry
jason-lynch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| kind: Fixed | ||
| body: Fixed global Patroni parameters not being applied to running systemd-managed database clusters — Dynamic configuration changes are now patched directly via the Patroni API on the primary instance, ensuring parameters that cannot be changed via config file reload take effect immediately. | ||
| body: Fixed global Patroni parameters not being applied to running database clusters. Dynamic configuration changes are now patched directly via the Patroni API on the primary instance, ensuring parameters that cannot be changed via config file reload take effect immediately. | ||
| time: 2026-06-11T09:00:00.000000-04:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| //go:build e2e_test | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/jackc/pgx/v5" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // HeartBeat is a helper to create a low, consistent volume of activity on a | ||
| // node to avoid replication stalls and waits. | ||
| type HeartBeat struct { | ||
| DB *DatabaseFixture | ||
| NodeName string | ||
| Username string | ||
| Password string | ||
| wg sync.WaitGroup | ||
| cancel context.CancelFunc | ||
| done chan struct{} | ||
| } | ||
|
|
||
| // RunHeartBeat starts a heartbeat for the given node. The heartbeat is | ||
| // automatically stopped during test cleanup. | ||
| func RunHeartBeat(t testing.TB, db *DatabaseFixture, username, password, nodeName string) { | ||
| t.Helper() | ||
|
|
||
| heartbeat := &HeartBeat{ | ||
| DB: db, | ||
| NodeName: nodeName, | ||
| Username: username, | ||
| Password: password, | ||
| } | ||
| heartbeat.Start(t) | ||
| t.Cleanup(func() { | ||
| heartbeat.Stop(t) | ||
| }) | ||
| } | ||
|
|
||
| func (l *HeartBeat) Start(t testing.TB) { | ||
| t.Helper() | ||
|
|
||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| l.cancel = cancel | ||
| l.done = make(chan struct{}) | ||
| l.wg.Go(func() { | ||
| defer l.cancel() | ||
|
|
||
| l.DB.WithConnection(ctx, l.connOpts(), t, func(conn *pgx.Conn) { | ||
| // Create table if not exists | ||
| l.createTable(ctx, t, conn) | ||
|
|
||
| // Persist heartbeat until Stop() is called | ||
| l.heartbeat(ctx, t, conn) | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| func (l *HeartBeat) Stop(t testing.TB) { | ||
| tLogf(t, "HeartBeat: stopping heartbeat on primary instance of node %s", l.NodeName) | ||
|
|
||
| close(l.done) | ||
| l.wg.Wait() | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| func (l *HeartBeat) connOpts() ConnectionOptions { | ||
| return ConnectionOptions{ | ||
| Matcher: And( | ||
| WithNode(l.NodeName), | ||
| WithRole("primary"), | ||
| ), | ||
| Username: l.Username, | ||
| Password: l.Password, | ||
| } | ||
| } | ||
|
|
||
| func (l *HeartBeat) createTable(ctx context.Context, t testing.TB, conn *pgx.Conn) { | ||
| sql := `CREATE TABLE IF NOT EXISTS heartbeat ( | ||
| node_name TEXT PRIMARY KEY, | ||
| updated_at TIMESTAMPTZ | ||
| );` | ||
|
|
||
| _, err := conn.Exec(ctx, sql) | ||
| require.NoError(t, err) | ||
| } | ||
|
|
||
| func (l *HeartBeat) heartbeat(ctx context.Context, t testing.TB, conn *pgx.Conn) { | ||
| tLogf(t, "HeartBeat: starting heartbeat on primary instance of node %s", l.NodeName) | ||
|
|
||
| sql := `INSERT INTO heartbeat (node_name, updated_at) | ||
| VALUES (@node_name, now()) | ||
| ON CONFLICT (node_name) | ||
| DO UPDATE SET updated_at = EXCLUDED.updated_at;` | ||
|
|
||
| ticker := time.NewTicker(500 * time.Millisecond) | ||
| defer ticker.Stop() | ||
|
|
||
| for { | ||
| select { | ||
| case <-ctx.Done(): | ||
| return | ||
| case <-l.done: | ||
| return | ||
| case <-ticker.C: | ||
| _, err := conn.Exec(ctx, sql, pgx.NamedArgs{"node_name": l.NodeName}) | ||
| require.NoError(t, err) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.