Skip to content

fix: update global patroni params for systemd#398

Merged
jason-lynch merged 1 commit into
mainfrom
fix/PLAT-610/update-global-patroni-params
Jun 11, 2026
Merged

fix: update global patroni params for systemd#398
jason-lynch merged 1 commit into
mainfrom
fix/PLAT-610/update-global-patroni-params

Conversation

@jason-lynch

@jason-lynch jason-lynch commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Patroni disallows setting some parameters through the Patroni config file after the cluster is created. Instead, they must be set via the dynamic config API.

This commit adds functionality to the systemd Patroni config implementation to patch the dynamic config if the Patroni API is up and reports that it is the primary instance.

This commit only affects systemd clusters. I will implement this for Swarm clusters in a subsequent commit by migrating Swarm to use the common Patroni config resource.

Testing

# this only works with systemd so far
# start the dev-lima environment
make dev-lima-run

# in a new terminal, switch to the dev-lima environment
use-dev-lima

# ensure that the cluster is initialized
cp-init

# create a database with the default max_connections
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

# query the current max_connections
cp-psql -i storefront-n1-689qacsi -U admin -- -c 'SHOW max_connections'

# update the database with a different max_connections, e.g.
cp1-req update-database storefront <<EOF | cp-follow-task
{                  
  "id": "storefront",
  "spec": {
    "database_name": "storefront",
    "database_users": [
      {
        "username": "admin",
        "db_owner": true,
        "attributes": ["SUPERUSER", "LOGIN"]
      }
    ],
    "port": 0,
    "patroni_port": 0,
    "nodes": [
      { "name": "n1", "host_ids": ["host-1"] }
    ],
    "postgresql_conf": {
      "max_connections": 900
    }
  }
}
EOF

# query the updated max_connections
cp-psql -i storefront-n1-689qacsi -U admin -- -c 'SHOW max_connections'

PLAT-610

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jason-lynch, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 32 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: acec50ed-5a73-49e5-8cce-ba234f069dc9

📥 Commits

Reviewing files that changed from the base of the PR and between 8cc83a1 and 8da1336.

📒 Files selected for processing (14)
  • e2e/patroni_global_params_test.go
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/enable_fast_basebackup.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/in-place_restore.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/minimal_swarm.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/minimal_systemd.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/user_pg_hba_pg_ident_and_scram.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/with_backup_config.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/with_restore_config.yaml
  • server/internal/orchestrator/common/patroni_config.go
  • server/internal/orchestrator/common/patroni_config_generator.go
  • server/internal/orchestrator/common/patroni_config_generator_test.go
  • server/internal/orchestrator/systemd/patroni_config.go
  • server/internal/patroni/client.go
  • server/internal/patroni/config.go
📝 Walkthrough

Walkthrough

Adds Patroni DCS-to-dynamic-config conversion and schema updates, wires NodeSize-driven failsafe_mode in the config generator, implements PatroniConfig create/update/delete with dynamic wait computation and optional dynamic-config patching, updates systemd reload wiring, updates golden tests and generator tests, and adds an e2e verifying max_connections update.

Changes

Patroni Dynamic Config Update Feature

Layer / File(s) Summary
Patroni client schema
server/internal/patroni/client.go
DynamicConfig.Pause becomes *bool; DynamicStandbyClusterConfig.CreateReplicaMethods becomes *[]string; RecoveryMinApplyDelay becomes *int.
DCS-to-Dynamic conversion
server/internal/patroni/config.go
Added ToDynamicConfig() for DCSPostgreSQL, DCSStandbyCluster, and DCS; renamed SynchronousModeCountSynchronousNodeCount and MemberSlotsTtl*int.
Failsafe Mode in generator
server/internal/orchestrator/common/patroni_config_generator.go
Added NodeSize to PatroniConfigGenerator, wired from instance spec; generator sets FailsafeMode true when NodeSize==1, else false.
PatroniConfig create/update/delete & helpers
server/internal/orchestrator/common/patroni_config.go
Create delegates to internal helper that returns generated config; Update computes reload wait from dynamic config and instance status, attempts dynamic-config patch when primary (logs on failure), and invokes a reload callback with computed wait; added client and getStatusInfo helpers; Delete tolerates missing file.
systemd orchestrator integration
server/internal/orchestrator/systemd/patroni_config.go
Extracted getAddresses helper; Create/Update reuse it and delegate to base with signalReload callback; signalReload accepts dynamic wait duration and sleeps that duration post-reload.
Golden test outputs
server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/*.yaml
Inserted failsafe_mode in bootstrap DCS for generator golden outputs (true for single-node swarm, false otherwise).
Config generator tests
server/internal/orchestrator/common/patroni_config_generator_test.go
Updated expected InstanceSpec entries to include NodeSize across generator test cases.
E2E test for global params
e2e/patroni_global_params_test.go
New build-tagged e2e test reads pg_settings.max_connections, updates PostgresqlConf["max_connections"] to +1 via fixture update, and verifies the database reflects the incremented value.

🐰 A config update hops through the meadow,
Dynamic patches drift like morning's shadow,
Failsafe modes bloom—one node or many—
Patroni reloads, swift as a bunny!
Test it end-to-end, the flow is merry,
Settings change graceful, never scary.

🚥 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 clearly and specifically describes the main change: enabling global Patroni parameter updates for systemd clusters by adding dynamic config patching support.
Description check ✅ Passed The description includes all required sections: a clear summary explaining the problem and solution, a detailed list of changes, comprehensive testing instructions with manual steps, and a filled-out checklist with issue reference (PLAT-610).
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/PLAT-610/update-global-patroni-params

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.

@codacy-production

codacy-production Bot commented Jun 3, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 2 medium

Results:
2 new issues

Category Results
Complexity 2 medium

View in Codacy

🟢 Metrics -4 duplication

Metric Results
Duplication -4

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
server/internal/orchestrator/common/patroni_config.go (1)

252-261: 💤 Low value

Computed wait can be negative when DCSLastSeen is stale but within bounds.

When lastSeen is between loopWait and 2*loopWait in the past (e.g., 15s ago with a 10s loop), time.Until(lastSeen.Add(loopWait)) returns a negative duration. While utils.SleepContext likely treats negative durations as zero, clamping explicitly would clarify intent.

Suggested fix
 		if lastSeen.After(lowerBound) && lastSeen.Before(upperBound) {
 			// Compute the time until the next run cycle
 			wait = time.Until(lastSeen.Add(loopWait))
+			if wait < 0 {
+				wait = 0
+			}
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/internal/orchestrator/common/patroni_config.go` around lines 252 -
261, The computed wait based on DCSLastSeen can be negative; in the block that
computes wait using time.Until(lastSeen.Add(loopWait)) (involving
status.DCSLastSeen, lastSeen, loopWait and wait), clamp the computed duration to
a non-negative value before assigning to wait (e.g., compute d :=
time.Until(lastSeen.Add(loopWait)); if d < 0 { d = 0 }; wait = d) so the code
explicitly prevents negative sleeps (which utils.SleepContext may otherwise
treat as zero).
e2e/patroni_global_params_test.go (1)

13-50: 💤 Low value

Minor: DatabaseName doesn't reflect what the test validates.

The test validates max_connections changes, but DatabaseName is "test_port_change". Consider renaming to "test_max_connections" or similar for clarity.

Suggested fix
 	db := fixture.NewDatabaseFixture(ctx, t, &api.CreateDatabaseRequest{
 		Spec: &api.DatabaseSpec{
-			DatabaseName: "test_port_change",
+			DatabaseName: "test_max_connections",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/patroni_global_params_test.go` around lines 13 - 50, Rename the test
database name to reflect what the test asserts: update the DatabaseName field in
the CreateDatabaseRequest's Spec (inside TestUpdatePatroniGlobalParams) from
"test_port_change" to a clearer name like "test_max_connections" so the
identifier matches the test intent; update any local references/comments that
mention the old name to keep wording consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@e2e/patroni_global_params_test.go`:
- Around line 13-50: Rename the test database name to reflect what the test
asserts: update the DatabaseName field in the CreateDatabaseRequest's Spec
(inside TestUpdatePatroniGlobalParams) from "test_port_change" to a clearer name
like "test_max_connections" so the identifier matches the test intent; update
any local references/comments that mention the old name to keep wording
consistent.

In `@server/internal/orchestrator/common/patroni_config.go`:
- Around line 252-261: The computed wait based on DCSLastSeen can be negative;
in the block that computes wait using time.Until(lastSeen.Add(loopWait))
(involving status.DCSLastSeen, lastSeen, loopWait and wait), clamp the computed
duration to a non-negative value before assigning to wait (e.g., compute d :=
time.Until(lastSeen.Add(loopWait)); if d < 0 { d = 0 }; wait = d) so the code
explicitly prevents negative sleeps (which utils.SleepContext may otherwise
treat as zero).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 282e42d3-0776-46a4-9147-ea9e7f712be1

📥 Commits

Reviewing files that changed from the base of the PR and between 3fb1e15 and d2fa9fa.

📒 Files selected for processing (13)
  • e2e/patroni_global_params_test.go
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/enable_fast_basebackup.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/in-place_restore.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/minimal_swarm.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/minimal_systemd.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/with_backup_config.yaml
  • server/internal/orchestrator/common/golden_test/TestPatroniConfigGenerator/with_restore_config.yaml
  • server/internal/orchestrator/common/patroni_config.go
  • server/internal/orchestrator/common/patroni_config_generator.go
  • server/internal/orchestrator/common/patroni_config_generator_test.go
  • server/internal/orchestrator/systemd/patroni_config.go
  • server/internal/patroni/client.go
  • server/internal/patroni/config.go

@jason-lynch jason-lynch force-pushed the fix/PLAT-610/update-global-patroni-params branch from d2fa9fa to 775fef7 Compare June 3, 2026 20:36
@jason-lynch jason-lynch marked this pull request as ready for review June 3, 2026 20:52
@jason-lynch jason-lynch force-pushed the fix/PLAT-610/update-global-patroni-params branch from 775fef7 to 8cc83a1 Compare June 9, 2026 19:55
Patroni disallows setting some parameters through the Patroni config
file after the cluster is created. Instead, they must be set via the
dynamic config API.

This commit adds functionality to the systemd Patroni config
implementation to patch the dynamic config if the Patroni API is up and
if the API reports that it is the primary instance.

This commit only affects systemd clusters. I will implement this for
Swarm clusters in a subsequent commit by migrating Swarm to use the
common Patroni config resource.

PLAT-610
@jason-lynch jason-lynch force-pushed the fix/PLAT-610/update-global-patroni-params branch from 8cc83a1 to 8da1336 Compare June 9, 2026 20:13

@tsivaprasad tsivaprasad left a comment

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.

Looks Good...!

➜  control-plane git:(fix/PLAT-610/update-global-patroni-params) 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

{
  "database": {
    "created_at": "2026-06-11T19:45:12+05:30",
    "id": "storefront",
    "spec": {
      "database_name": "storefront",
      "database_users": [
        {
          "attributes": [
            "SUPERUSER",
            "LOGIN"
          ],
          "db_owner": true,
          "username": "admin"
        }
      ],
      "nodes": [
        {
          "host_ids": [
            "host-1"
          ],
          "name": "n1"
        }
      ],
      "patroni_port": 0,
      "port": 0,
      "postgres_version": "18.4",
      "spock_version": "5"
    },
    "state": "creating",
    "updated_at": "2026-06-11T19:45:12+05:30"
  },
  "task": {
    "created_at": "2026-06-11T19:45:12+05:30",
    "database_id": "storefront",
    "entity_id": "storefront",
    "scope": "database",
    "status": "pending",
    "task_id": "019eb709-7a2a-714a-8440-16aa4b71afb5",
    "type": "create"
  }
}
[2026-06-11T19:45:13+05:30] refreshing current state
[2026-06-11T19:45:13+05:30] finished refreshing current state (took 192.176787ms)
[2026-06-11T19:45:15+05:30] creating resource common.patroni_cluster::n1
[2026-06-11T19:45:15+05:30] finished creating resource common.patroni_cluster::n1 (took 21.584µs)
[2026-06-11T19:45:15+05:30] creating resource filesystem.dir::storefront-n1-689qacsi-instance
[2026-06-11T19:45:15+05:30] finished creating resource filesystem.dir::storefront-n1-689qacsi-instance (took 2.615176ms)
[2026-06-11T19:45:15+05:30] creating resource common.patroni_member::storefront-n1-689qacsi
[2026-06-11T19:45:15+05:30] finished creating resource common.patroni_member::storefront-n1-689qacsi (took 60.125µs)
[2026-06-11T19:45:15+05:30] creating resource filesystem.dir::storefront-n1-689qacsi-data
[2026-06-11T19:45:15+05:30] finished creating resource filesystem.dir::storefront-n1-689qacsi-data (took 988.378µs)
[2026-06-11T19:45:15+05:30] creating resource filesystem.dir::storefront-n1-689qacsi-certificates
[2026-06-11T19:45:15+05:30] finished creating resource filesystem.dir::storefront-n1-689qacsi-certificates (took 677.253µs)
[2026-06-11T19:45:15+05:30] creating resource filesystem.dir::storefront-n1-689qacsi-configs
[2026-06-11T19:45:15+05:30] finished creating resource filesystem.dir::storefront-n1-689qacsi-configs (took 381.918µs)
[2026-06-11T19:45:16+05:30] creating resource common.etcd_creds::storefront-n1-689qacsi
[2026-06-11T19:45:16+05:30] creating resource common.postgres_certs::storefront-n1-689qacsi
[2026-06-11T19:45:16+05:30] finished creating resource common.postgres_certs::storefront-n1-689qacsi (took 11.029913ms)
[2026-06-11T19:45:16+05:30] finished creating resource common.etcd_creds::storefront-n1-689qacsi (took 78.574354ms)
[2026-06-11T19:45:16+05:30] creating resource systemd.patroni_config::storefront-n1-689qacsi
[2026-06-11T19:45:16+05:30] finished creating resource systemd.patroni_config::storefront-n1-689qacsi (took 3.616929ms)
[2026-06-11T19:45:16+05:30] creating resource systemd.unit::patroni-storefront-n1-689qacsi.service:storefront:host-1
[2026-06-11T19:45:16+05:30] finished creating resource systemd.unit::patroni-storefront-n1-689qacsi.service:storefront:host-1 (took 163.170313ms)
[2026-06-11T19:45:17+05:30] creating resource database.instance::storefront-n1-689qacsi
[2026-06-11T19:45:27+05:30] finished creating resource database.instance::storefront-n1-689qacsi (took 10.038586483s)
[2026-06-11T19:45:27+05:30] creating resource database.node::n1
[2026-06-11T19:45:27+05:30] finished creating resource database.node::n1 (took 79.291µs)
[2026-06-11T19:45:27+05:30] creating resource monitor.instance::storefront-n1-689qacsi
[2026-06-11T19:45:27+05:30] finished creating resource monitor.instance::storefront-n1-689qacsi (took 11.249455ms)
[2026-06-11T19:45:28+05:30] creating resource common.pg_service_conf::storefront-n1-689qacsi
[2026-06-11T19:45:28+05:30] finished creating resource common.pg_service_conf::storefront-n1-689qacsi (took 1.353088ms)
[2026-06-11T19:45:28+05:30] creating resource database.postgres_database::n1:storefront
[2026-06-11T19:45:28+05:30] finished creating resource database.postgres_database::n1:storefront (took 286.266736ms)

database entity storefront task 019eb709-7a2a-714a-8440-16aa4b71afb5 completed
➜  control-plane git:(fix/PLAT-610/update-global-patroni-params) cp-psql -i storefront-n1-689qacsi -U admin -- -c 'SHOW max_connections'

 max_connections 
-----------------
 843
(1 row)

➜  control-plane git:(fix/PLAT-610/update-global-patroni-params) cp1-req update-database storefront <<EOF | cp-follow-task
{
  "id": "storefront",
  "spec": {
    "database_name": "storefront",
    "database_users": [
      {
        "username": "admin",
        "db_owner": true,
        "attributes": ["SUPERUSER", "LOGIN"]
      }
    ],
    "port": 0,
    "patroni_port": 0,
    "nodes": [
      { "name": "n1", "host_ids": ["host-1"] }
    ],
    "postgresql_conf": {
      "max_connections": 900
    }
  }
}
EOF

{
  "database": {
    "created_at": "2026-06-11T19:45:12+05:30",
    "id": "storefront",
    "instances": [
      {
        "connection_info": {
          "addresses": [
            "127.0.0.1"
          ],
          "port": 6325
        },
        "created_at": "2026-06-11T19:45:14+05:30",
        "host_id": "host-1",
        "id": "storefront-n1-689qacsi",
        "node_name": "n1",
        "postgres": {
          "patroni_state": "running",
          "role": "primary",
          "version": "18.4"
        },
        "spock": {
          "read_only": "off",
          "version": "5.0.8"
        },
        "state": "available",
        "status_updated_at": "2026-06-11T19:46:47+05:30",
        "updated_at": "2026-06-11T19:45:27+05:30"
      }
    ],
    "spec": {
      "database_name": "storefront",
      "database_users": [
        {
          "attributes": [
            "SUPERUSER",
            "LOGIN"
          ],
          "db_owner": true,
          "username": "admin"
        }
      ],
      "nodes": [
        {
          "host_ids": [
            "host-1"
          ],
          "name": "n1"
        }
      ],
      "patroni_port": 0,
      "port": 0,
      "postgres_version": "18.4",
      "postgresql_conf": {
        "max_connections": 900
      },
      "spock_version": "5"
    },
    "state": "modifying",
    "updated_at": "2026-06-11T19:46:51+05:30"
  },
  "task": {
    "created_at": "2026-06-11T19:46:51+05:30",
    "database_id": "storefront",
    "entity_id": "storefront",
    "scope": "database",
    "status": "pending",
    "task_id": "019eb70a-fe7b-7791-bba3-50e1be1b6c75",
    "type": "update"
  }
}
[2026-06-11T19:46:52+05:30] refreshing current state
[2026-06-11T19:47:00+05:30] finished refreshing current state (took 7.999740163s)
[2026-06-11T19:47:02+05:30] updating resource systemd.patroni_config::storefront-n1-689qacsi
[2026-06-11T19:47:09+05:30] finished updating resource systemd.patroni_config::storefront-n1-689qacsi (took 6.877566085s)
[2026-06-11T19:47:09+05:30] updating resource systemd.unit::patroni-storefront-n1-689qacsi.service:storefront:host-1
[2026-06-11T19:47:09+05:30] finished updating resource systemd.unit::patroni-storefront-n1-689qacsi.service:storefront:host-1 (took 176.99861ms)
[2026-06-11T19:47:09+05:30] updating resource database.instance::storefront-n1-689qacsi
[2026-06-11T19:47:26+05:30] finished updating resource database.instance::storefront-n1-689qacsi (took 16.416024886s)
[2026-06-11T19:47:26+05:30] updating resource database.node::n1
[2026-06-11T19:47:26+05:30] finished updating resource database.node::n1 (took 126.417µs)
[2026-06-11T19:47:26+05:30] updating resource monitor.instance::storefront-n1-689qacsi
[2026-06-11T19:47:26+05:30] finished updating resource monitor.instance::storefront-n1-689qacsi (took 15.618679ms)
[2026-06-11T19:47:27+05:30] updating resource common.pg_service_conf::storefront-n1-689qacsi
[2026-06-11T19:47:27+05:30] finished updating resource common.pg_service_conf::storefront-n1-689qacsi (took 903.711µs)
[2026-06-11T19:47:27+05:30] updating resource database.postgres_database::n1:storefront
[2026-06-11T19:47:27+05:30] finished updating resource database.postgres_database::n1:storefront (took 35.183121ms)

database entity storefront task 019eb70a-fe7b-7791-bba3-50e1be1b6c75 completed
➜  control-plane git:(fix/PLAT-610/update-global-patroni-params) cp-psql -i storefront-n1-689qacsi -U admin -- -c 'SHOW max_connections'

 max_connections 
-----------------
 900
(1 row)

}
if isPrimary && cfg.Bootstrap != nil && cfg.Bootstrap.DCS != nil {
_, err := client.PatchDynamicConfig(ctx, cfg.Bootstrap.DCS.ToDynamicConfig())
if err != nil {

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.

If Patroni rejects the request with a 4xx response (for example, due to an invalid parameter value), this currently treats the update as successful. Should we return an error instead of logging a warning and continuing?

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.

That's a good question. PatchDynamicConfig should return an error if it gets a 4xx or other unsuccessful response. We have a helper method in that package to validate response codes:

func successful(resp *http.Response) bool {
return resp.StatusCode >= 200 && resp.StatusCode < 300
}

And then we call it in each client method, like we do here in PatchDynamicConfig:

if !successful(resp) {
body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("failed to patch dynamic config: %d %s", resp.StatusCode, body)
}

Does that address your concern, or is there an issue in this implementation?

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.

Oh, okay. Thanks! Looks good now — please go ahead and merge it.

@jason-lynch jason-lynch merged commit dbb5df5 into main Jun 11, 2026
3 checks passed
@jason-lynch jason-lynch deleted the fix/PLAT-610/update-global-patroni-params branch June 11, 2026 15:25
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