Skip to content

Commit 31369d4

Browse files
authored
refactor: remove overlay database support (#12)
1 parent 7fa9584 commit 31369d4

24 files changed

Lines changed: 134 additions & 3962 deletions

.github/workflows/integration.yml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,35 @@ jobs:
3232
test-rw-schema
3333
test-ro-schema
3434
needs_non_pg_snapshot: false
35-
needs_cnpg: false
36-
3735
- name: error_paths
3836
namespaces: >-
3937
test-non-pg-data
4038
test-wrong-bucket
4139
needs_non_pg_snapshot: true
42-
needs_cnpg: false
4340

4441
- name: ttls
4542
namespaces: >-
4643
test-min-ttl
4744
needs_non_pg_snapshot: true
48-
needs_cnpg: false
4945

5046
- name: switchover
5147
namespaces: >-
5248
test-switchover
5349
needs_non_pg_snapshot: false
54-
needs_cnpg: false
55-
56-
- name: overlay
57-
namespaces: >-
58-
test-overlay
59-
test-overlay-copy
60-
needs_non_pg_snapshot: false
61-
needs_cnpg: true
6250

6351
- name: consecutive_failures
6452
namespaces: >-
6553
test-consecutive-failures
6654
test-phase-stuck
6755
test-subresource-reset
6856
needs_non_pg_snapshot: true
69-
needs_cnpg: false
7057

7158
- name: persistent_schemas
7259
namespaces: >-
7360
test-persistent-schemas
7461
test-ps-conflict
7562
test-ps-skip-missing
7663
needs_non_pg_snapshot: false
77-
needs_cnpg: false
7864

7965
steps:
8066
- uses: actions/checkout@v6
@@ -177,27 +163,6 @@ jobs:
177163
load_image postgres:16-alpine
178164
load_image alpine:latest
179165
180-
- name: Pre-pull CNPG images
181-
if: matrix.needs_cnpg
182-
run: |
183-
load_image() {
184-
local image="$1"
185-
local archive="/tmp/$(echo "$image" | tr '/:' '_').tar"
186-
crane pull --platform linux/amd64 "$image" "$archive"
187-
kind load image-archive "$archive"
188-
rm -f "$archive"
189-
}
190-
191-
load_image ghcr.io/cloudnative-pg/cloudnative-pg:1.25.1
192-
load_image ghcr.io/cloudnative-pg/postgresql:17
193-
194-
- name: Install CNPG operator
195-
if: matrix.needs_cnpg
196-
run: |
197-
kubectl apply --server-side -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.25/releases/cnpg-1.25.1.yaml
198-
kubectl wait --for=condition=Available deployment/cnpg-controller-manager -n cnpg-system --timeout=120s
199-
echo "CNPG operator is ready"
200-
201166
- name: Deploy MinIO
202167
run: |
203168
kubectl apply -f tests/fixtures/minio.yaml
@@ -310,9 +275,6 @@ jobs:
310275
kubectl get all -n "$ns" 2>/dev/null || true
311276
done
312277
313-
echo "=== CNPG Clusters ==="
314-
kubectl get clusters.postgresql.cnpg.io -A -o yaml 2>/dev/null || true
315-
316278
echo "=== PostgresPhysicalReplicas ==="
317279
kubectl get postgresphysicalreplicas -A -o yaml 2>/dev/null || true
318280

README.md

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ Defines a continuously-refreshed replica of a PostgreSQL database restored from
102102
| `readOnly` | `bool` | No | `true` | Set the restored database to read-only mode. |
103103
| `postgresExtraConfig` | `string` | No | — | Extra lines appended to `postgresql.conf` (e.g. `shared_preload_libraries`). |
104104
| `notifications` | `[]NotificationConfig` | No | `[]` | Notification targets called on restore events. |
105-
| `overlayDatabase` | `OverlayDatabaseConfig` | No | — | Optional overlay database configuration (persistent database via CNPG). Mutually exclusive with `persistentSchemas`. |
106-
| `persistentSchemas` | `[]string` | No | — | List of schema names to migrate from the old restore to the new restore on each switchover. Mutually exclusive with `overlayDatabase`. |
107-
108-
Using the `overlayDatabase` requires the CloudNative-PG operator to be installed and configured.
109-
Installing the CNPG cluster-level catalogs is optional but recommended.
105+
| `persistentSchemas` | `[]string` | No | — | List of schema names to migrate from the previous restore to the new restore on each switchover. |
110106

111107
The cron expression is parsed using the [cronexpr](https://docs.rs/cronexpr) crate.
112108
It has two interesting features:
@@ -151,34 +147,6 @@ Additional fields for `target: graphQL`:
151147
| `mutation` | `string` | Yes | GraphQL mutation string. |
152148
| `variablesTemplate` | `string` | Yes | Template for the GraphQL variables payload. |
153149

154-
#### OverlayDatabaseConfig
155-
156-
Configures an overlay database backed by a CNPG Cluster that imports schemas from the restored replica.
157-
Two strategies are available: `fdw` (Foreign Data Wrappers, the default) and `copy` (`pg_dump | psql`).
158-
The `copy` strategy tolerates PostgreSQL version differences and does not require the restore to stay alive after the copy completes.
159-
This can be used to persistently write data in other schemas in the overlay without interfacing between two databases.
160-
161-
| Field | Type | Required | Default | Description |
162-
|-------|------|----------|---------|-------------|
163-
| `strategy` | `"fdw"` \| `"copy"` | No | `"fdw"` | Strategy for populating the overlay from the restore. `fdw` creates foreign tables (restore must stay alive). `copy` uses `pg_dump \| psql` to copy data (tolerates version differences, restore can be discarded). |
164-
| `postgresVersion` | `uint32` | No | Resolved from image catalog, or `18` | PostgreSQL major version for the CNPG cluster. |
165-
| `imageCatalog` | `ImageCatalogRef` | No | ClusterImageCatalog | CNPG image catalog for PG version discovery and image resolution. |
166-
| `storageSizeOverride` | `Quantity` | No | Auto-sized | Override for the overlay PVC size. Auto-sizing: `5Gi + ceil(snapshotSize / 10)`, ratchets up only. |
167-
| `storageClass` | `string` | No | — | Storage class for the overlay database PVC. |
168-
| `resources` | `ResourceRequirements` | No | — | Resource requirements for the overlay database pods. |
169-
| `affinity` | `Affinity` | No | — | Pod affinity rules for the overlay database. |
170-
| `tolerations` | `[]Toleration` | No | `[]` | Tolerations for the overlay database pods. |
171-
| `serviceAnnotations` | `map[string]string` | No | — | Annotations for the overlay database's `-rw` Service. |
172-
| `importGenerated` | `bool` | No | `false` | Include `GENERATED` column expressions when importing foreign schemas (FDW only). Ignored for `copy` strategy. |
173-
| `retainRestore` | `bool` | No | `true` | When `false` and strategy is `copy`, delete the restore Deployment and PVC after a successful copy. The restore CR is kept for bookkeeping. Ignored for `fdw` strategy. |
174-
175-
#### ImageCatalogRef
176-
177-
| Field | Type | Required | Default | Description |
178-
|-------|------|----------|---------|-------------|
179-
| `name` | `string` | Yes | — | Name of the image catalog resource. |
180-
| `kind` | `string` | No | `"ClusterImageCatalog"` | Kind of the image catalog (`ClusterImageCatalog` or `ImageCatalog`). |
181-
182150
#### Status
183151

184152
| Field | Type | Description |
@@ -194,10 +162,6 @@ This can be used to persistently write data in other schemas in the overlay with
194162
| `queuePosition` | `uint32` | Position in the global restore queue. |
195163
| `notifications` | `[]NotificationStatus` | Status of each configured notification target. |
196164
| `conditions` | `[]Condition` | Standard Kubernetes conditions. |
197-
| `overlayClusterName` | `string` | Name of the CNPG Cluster CR for the overlay database. |
198-
| `overlayRestore` | `string` | Name of the restore whose schemas are currently imported into the overlay. |
199-
| `overlayStorageSize` | `Quantity` | Current (possibly ratcheted) storage size of the overlay PVC. |
200-
| `overlayPostgresVersion` | `uint32` | Resolved PG major version used for the overlay cluster. |
201165
| `schemaMigrationJob` | `string` | Name of the active schema migration Job (set while migration is in progress). |
202166
| `schemaMigrationPhase` | `string` | Phase of the schema migration (`active`, `complete`, or `failed: <reason>`). |
203167
| `persistentSchemaDataSize` | `Quantity` | Measured size of persistent schema data from the last successful migration. Used to size the next restore PVC. |

src/bin/operator.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,6 @@ fn build_router(state: ServerState, metrics_registry: prometheus::Registry) -> R
380380
"/api/v1/snapshot-results/{namespace}/{replica}",
381381
axum::routing::post(post_snapshot_results),
382382
)
383-
.route(
384-
"/api/v1/copy-results/{namespace}/{replica}",
385-
axum::routing::post(post_copy_results),
386-
)
387383
.route(
388384
"/api/v1/schema-migration-results/{namespace}/{replica}",
389385
axum::routing::post(post_schema_migration_results),
@@ -408,24 +404,6 @@ async fn post_snapshot_results(
408404
StatusCode::NO_CONTENT
409405
}
410406

411-
/// Accept copy-job result POSTed by a job.
412-
///
413-
/// Body is plain text: `"success"` on success, or the error output on failure.
414-
async fn post_copy_results(
415-
State(state): State<ServerState>,
416-
Path((namespace, replica)): Path<(String, String)>,
417-
body: String,
418-
) -> StatusCode {
419-
info!(
420-
namespace = namespace,
421-
replica = replica,
422-
bytes = body.len(),
423-
"received copy results callback"
424-
);
425-
state.ctx.copy_results.store(&namespace, &replica, body);
426-
StatusCode::NO_CONTENT
427-
}
428-
429407
async fn post_schema_migration_results(
430408
State(state): State<ServerState>,
431409
Path((namespace, replica)): Path<(String, String)>,

src/context.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ pub struct Context {
2222
pub http_client: reqwest::Client,
2323
/// In-memory store for snapshot-list results POSTed by jobs.
2424
pub snapshot_results: Arc<CallbackStore>,
25-
/// In-memory store for overlay copy results POSTed by jobs.
26-
pub copy_results: Arc<CallbackStore>,
2725
/// In-memory store for schema migration results POSTed by jobs.
2826
pub schema_migration_results: Arc<CallbackStore>,
2927
/// Base URL the operator is reachable at from within the cluster,
@@ -55,7 +53,6 @@ impl Context {
5553
use_port_forward: Arc::new(AtomicBool::new(use_port_forward)),
5654
http_client: reqwest::Client::new(),
5755
snapshot_results: Arc::new(CallbackStore::default()),
58-
copy_results: Arc::new(CallbackStore::default()),
5956
schema_migration_results: Arc::new(CallbackStore::default()),
6057
callback_base_url,
6158
last_reconcile: Arc::new(AtomicI64::new(Timestamp::now().as_second())),
@@ -82,14 +79,6 @@ impl Context {
8279
)
8380
}
8481

85-
/// Build the callback URL for a copy job to POST results to.
86-
pub fn copy_callback_url(&self, namespace: &str, replica: &str) -> String {
87-
format!(
88-
"{}/api/v1/copy-results/{namespace}/{replica}",
89-
self.callback_base_url
90-
)
91-
}
92-
9382
/// Build the callback URL for a schema migration job to POST results to.
9483
pub fn schema_migration_callback_url(&self, namespace: &str, replica: &str) -> String {
9584
format!(

src/controllers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use k8s_openapi::api::core::v1::{EnvVar, EnvVarSource, Pod, SecretKeySelector, S
22
use kube::{Api, Client};
33

44
pub mod jobs;
5-
pub mod overlay;
5+
pub mod postgres;
66
pub mod replica;
77
pub mod restore;
88

src/controllers/overlay.rs

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)