You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 501bc4f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(mongodb): key system-bucket injection off the app flag, not live storage
Review of the useSystemBucket flow surfaced three defects rooted in the
driver deciding what to do from the live cluster's storage set rather than
from the app's opt-in.
The snapshot fallback fired for legacy apps too. Its gate was
`snap.S3 == nil && rendered.S3 != nil`, but the coordinates moved onto the
shared cozy-default strategy, so rendered.S3 is now non-nil for every
MongoDB app. A legacy backup written to the tenant's own bucket got its
snapshot rewritten to the platform bucket, sending restore to the wrong
place. Gate the fallback on the app's backup.useSystemBucket flag instead,
threaded through createMongoDBBackupArtifact, and pin the legacy case.
The injected storage never caught up with the strategy. Injection was
gated on the named storage being absent, so it ran once per cluster and
froze the coordinates at the first backup; a later endpoint/region change
or bucket re-provision was a silent no-op, and Helm could not repair it
because the useSystemBucket chart renders no storages. Key injection off
the app flag and re-apply on every BackupJob (the prefix is deterministic,
so this never splits the archive the way CNPG's serverName would). Add
UseSystemBucket to mongodbapp.MongoDBSpec so a legacy app is protected by
the flag, not by whatever happens to be on the cluster.
Docs said the opposite of what the driver does. backup-classes.md claimed
"the MongoDB driver cannot inject its S3 target per-backup"; correct it and
add an opt-in-to-the-system-bucket section that names which values stop
being read and that scheduled backups + PITR must move to a Plan. Fix the
endpoint table row, the tuning reference, the RBAC comment that said the
driver never patches, the strategy header/inline comments, and the example
comment. Also assert notExists on spec.backup.pitr in the helm test, and
lift the duplicated cozy-backups-creds default into a const.
Signed-off-by: Andrey Kolkov <[email protected]>
Assisted-By: LLM
Copy file name to clipboardExpand all lines: docs/operations/backup-classes.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Different operators expect different endpoint shapes; the strategy templates ren
35
35
| CNPG (Postgres) |`barmanObjectStore.endpointURL`| full URL (scheme preserved) |
36
36
| Etcd |`destination.s3.endpoint`| full URL (scheme preserved) |
37
37
| MariaDB |`storage.s3.endpoint`| bare host:port (scheme stripped); `tls.enabled` derived from the scheme |
38
-
| MongoDB |n/a — storage lives on the app (`backup.endpointURL`)| full URL (scheme preserved), configured on the MongoDB application, not the strategy |
38
+
| MongoDB |`s3.endpointUrl`| full URL (scheme preserved); on the default flow the app's `backup.endpointURL`, on `useSystemBucket`the strategy coordinate injected by the driver|
39
39
| FoundationDB |`blobStoreConfiguration.accountName` + `urlParameters.secure_connection`| bare host:port + derived secure flag |
40
40
| Velero |`BackupStorageLocation.spec.config.s3Url`| full URL (scheme preserved) |
`s3Region`, `s3Bucket`, `endpoint`, `s3AccessKey`, `s3SecretKey`, and `s3CredentialsSecret` are ignored in this mode.
70
70
71
-
## MongoDB: the application owns the backup storage
71
+
## MongoDB: backup storage
72
72
73
-
Unlike CNPG / MariaDB / Altinity, the MongoDB driver cannot inject its S3 target per-backup: the Percona psmdb operator only runs the percona-backup-mongodb (pbm) agents and services `PerconaServerMongoDBBackup` CRs when the `PerconaServerMongoDB` cluster has `spec.backup.enabled: true` and a storage declared, and a `PerconaServerMongoDBBackup` references that storage only by name. So the MongoDB application must **opt into backups** and point at the bucket in its own chart values:
73
+
MongoDB supports two storage flows. By default the S3 target lives on the app CR and the tenant supplies its own credentials; alternatively the tenant opts into the platform system bucket and the driver injects the storage onto the live cluster at backup time.
74
+
75
+
### Default: the application owns the backup storage
76
+
77
+
The Percona psmdb operator only runs the percona-backup-mongodb (pbm) agents and services `PerconaServerMongoDBBackup` CRs when the `PerconaServerMongoDB` cluster has `spec.backup.enabled: true` and a storage declared, and a `PerconaServerMongoDBBackup` references that storage only by name. On the default flow the MongoDB application **opts into backups** and points at the bucket in its own chart values:
74
78
75
79
```yaml
76
80
apiVersion: apps.cozystack.io/v1alpha1
@@ -93,6 +97,25 @@ For a to-copy restore the operator reads the dump from the **source** backup's b
93
97
94
98
A full, scripted example (write a marker document, back up, restore to a copy, assert the round-trip while the source stays untouched) is in [`examples/backups/mongodb/`](../../examples/backups/mongodb/) — driven by `run-all.sh`.
95
99
100
+
### Opt-in to the system bucket
101
+
102
+
Unlike ClickHouse's sidecar, PBM takes the bucket/endpoint/prefix as static fields on the `PerconaServerMongoDB` CR, and the platform bucket name is only known at BackupJob time — so the chart cannot render them. Instead the `cozy-default-mongodb` driver injects the storage onto the live cluster. To back up to the platform bucket without supplying S3 credentials, set:
103
+
104
+
```yaml
105
+
backup:
106
+
enabled: true
107
+
useSystemBucket: true
108
+
```
109
+
110
+
When `useSystemBucket: true`:
111
+
112
+
- The chart-emitted `<release>-s3-creds` Secret is no longer rendered, and the chart leaves `spec.backup.storages`, `spec.backup.tasks` and `spec.backup.pitr` unset on the `PerconaServerMongoDB`.
113
+
- On every BackupJob the driver SSA-injects the `s3-storage` entry from the strategy coordinates (bucket/endpoint from the platform system bucket, `credentialsSecret: cozy-backups-creds`, prefix `<namespace>/<release>`) under its own field manager, so a Flux re-render never reverts it and a later change to the coordinates is picked up on the next backup rather than frozen at the first.
114
+
115
+
`destinationPath`, `endpointURL`, `insecureSkipTLSVerify`, `s3AccessKey` and `s3SecretKey` are ignored in this mode.
116
+
117
+
Because the chart drops `spec.backup.tasks` and `spec.backup.pitr`, the psmdb operator's own scheduled backups and oplog PITR do **not** run on this flow — `backup.schedule` and `backup.retentionPolicy` stay in the schema for the default flow but have no effect here, and the `recoveryTime` PITR restores described below are not available. Migrate scheduled backups to a `backups.cozystack.io/Plan` against `cozy-default` instead. **Flipping this flag on a running app** removes the storage, tasks and pitr the app had, so a release that was taking scheduled backups + PITR before the flip stops until a `Plan` takes over.
118
+
96
119
### Point-in-time recovery (MongoDB)
97
120
98
121
psmdb records an oplog stream between logical backups. A MongoDB `RestoreJob` recovers to a timestamp via `spec.options.recoveryTime` — the same option name and RFC3339 format the Postgres/CNPG driver uses, so the two are uniform:
@@ -240,7 +263,7 @@ The defaults aim at a reasonable middle (30-day retention, gzip compression wher
- **MongoDB strategy**: `storageName` (which `spec.backup.storages` entry on the psmdb cluster to use), `type` (`logical`), `compressionType` / `compressionLevel`. The S3 target itself is tuned via `backup.*` values on the MongoDB release (see [MongoDB: the application owns the backup storage](#mongodb-the-application-owns-the-backup-storage)).
266
+
- **MongoDB strategy**: `storageName` (which `spec.backup.storages` entry on the psmdb cluster to use), `type` (`logical`), `compressionType` / `compressionLevel`, and — for the `useSystemBucket` flow — the `s3` coordinates the driver injects. On the default flow the S3 target is tuned via `backup.*` values on the MongoDB release instead (see [MongoDB: backup storage](#mongodb-backup-storage)).
244
267
- **Altinity strategy**: tune the `clickhouse-backup` sidecar via `backup.*` values on the ClickHouse release; the strategy Pod is a thin HTTP client. When the S3 endpoint's certificate is signed by a private CA rather than a publicly-trusted one — SeaweedFS's in-cluster `:8333` being the case in point — point `backup.endpointCA` at a Secret holding that CA bundle; the chart mounts it into the sidecar and adds it to the trust store via `SSL_CERT_DIR`, which supplements the system CA set rather than replacing it.
0 commit comments