Skip to content

Conversation

dannyzaken
Copy link
Member

@dannyzaken dannyzaken commented Oct 9, 2025

Explain the changes

  1. This PR also includes a separate commit with noobaa-cnpg-integration.md doc.
  2. Added a design doc noobaa-cnpg-db-backup.md
  3. API Type Definitions - Extended NooBaaDBSpec and NooBaaDBStatus types to support backup and recovery.

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • New Features

    • Introduced configurable database backups using volume snapshots, including schedule, snapshot class, and retention limits.
    • Added recovery from a specified snapshot with clear recovery states (pending, running, completed, failed).
    • Enhanced status reporting: view last/next backup times, total and available snapshots, and recovery progress.
  • Documentation

    • Added a design guide for automated database backup and restore with CloudNative‑PG.
    • Added an integration overview for NooBaa with CloudNative‑PG, covering concepts, workflows, and operational guidance.

Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds database backup and recovery configuration to the NooBaa CRD and API types, supporting scheduled volume snapshot backups and recovery from a snapshot. Updates generated deepcopy methods and CRD bundle constants. Introduces two documentation files detailing CNPG integration and the backup/recovery design.

Changes

Cohort / File(s) Summary
CRD schema
deploy/crds/noobaa.io_noobaas.yaml
Extends OpenAPI schema: adds spec.dbSpec.dbBackup, spec.dbSpec.dbRecovery; adds status.dbStatus.backupStatus, status.dbStatus.recoveryStatus.
Bundle update (CRD content + hash)
pkg/bundle/deploy.go
Updates embedded CRD YAML constant and its SHA256 to match new schema fields.
Public API types
pkg/apis/noobaa/v1alpha1/noobaa_types.go
Adds DB backup/recovery spec and status types; updates NooBaaDBSpec, NooBaaDBStatus; introduces DBClusterStatusRecovering and DBRecoveryStatusType enum.
Generated deepcopy
pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go
Generates deepcopy methods for new types; updates existing deepcopy to include new fields and deep copy DBStatus.
Docs: backup/recovery design
doc/design/noobaa-cnpg-db-backup.md
New design doc describing automated backups via CNPG, retention, recovery flow, status, and CLI stubs.
Docs: CNPG integration
doc/noobaa-cnpg-integration.md
New overview doc of CNPG integration, concepts, operator phases, API group usage, and references.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant NooBaa CR as NooBaa CR (dbSpec)
  participant Operator as NooBaa Operator
  participant CNPG as CNPG Controller
  participant K8s as Kubernetes API
  participant VS as VolumeSnapshot

  rect rgb(245,248,255)
    note over User,Operator: Configure automated DB backups
    User->>K8s: Apply NooBaa with spec.dbSpec.dbBackup
    K8s-->>Operator: Reconcile NooBaa
    Operator->>K8s: Create/Update CNPG ScheduledBackup (VolumeSnapshotClass, schedule)
    CNPG->>K8s: Create VolumeSnapshot per schedule
    K8s-->>Operator: List snapshots
    Operator->>Operator: Enforce maxSnapshots (delete oldest)
    Operator->>K8s: Update NooBaa.status.dbStatus.backupStatus
  end

  alt Recovery configured
    note over User,Operator: Recovery from a snapshot
    User->>K8s: Update NooBaa spec.dbSpec.dbRecovery.volumeSnapshotName
    K8s-->>Operator: Reconcile NooBaa
    Operator->>K8s: Initiate CNPG bootstrap from VolumeSnapshot
    Operator->>K8s: Update recoveryStatus (Pending/Running)
    CNPG->>K8s: Restore PVCs/DB from snapshot
    CNPG-->>Operator: Completion/Failure event
    Operator->>K8s: Update recoveryStatus (Completed/Failed) and db cluster status
  else No recovery
    note over Operator: No recovery flow executed
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Update rook api #1709 — Also updates the embedded CRD and corresponding SHA in the bundle; this PR builds on similar CRD/schema changes.

Suggested labels

size/L

Suggested reviewers

  • nimrod-becker
  • liranmauda

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description follows the repository template by including all required section headings but leaves the “Issues: Fixed #xxx / Gap #xxx” and “Testing Instructions” sections empty and the checklist unchecked without details. Please fill in the relevant issue or gap numbers under the Issues section, provide concrete steps or commands in the Testing Instructions section, and update the checklist to reflect any added documentation or tests.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “DB Backup - Design doc and initial changes” clearly conveys that the pull request introduces a database backup feature along with design documentation and initial implementation work, making it concise and relevant to the main changes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22f1cc3 and 1cda15d.

📒 Files selected for processing (6)
  • deploy/crds/noobaa.io_noobaas.yaml (4 hunks)
  • doc/design/noobaa-cnpg-db-backup.md (1 hunks)
  • doc/noobaa-cnpg-integration.md (1 hunks)
  • pkg/apis/noobaa/v1alpha1/noobaa_types.go (3 hunks)
  • pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go (4 hunks)
  • pkg/bundle/deploy.go (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go (1)
pkg/apis/noobaa/v1alpha1/noobaa_types.go (4)
  • DBBackupSpec (378-387)
  • DBBackupStatus (557-569)
  • DBRecoverySpec (390-393)
  • DBRecoveryStatus (572-581)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: run-azure-vault-test
  • GitHub Check: run-cli-tests
  • GitHub Check: run-core-config-map-tests
  • GitHub Check: cnpg-deployment-test
  • GitHub Check: run-kms-tls-sa-test
  • GitHub Check: run-hac-test
  • GitHub Check: run-kms-kmip-test
  • GitHub Check: run-admission-test
  • GitHub Check: golangci-lint
  • GitHub Check: run-kms-dev-test
  • GitHub Check: run-kms-tls-token-test
  • GitHub Check: run-kms-key-rotate-test

Comment on lines +190 to +194
r.CNPGCluster.Spec.Backup = &cnpgv1.BackupConfiguration{
VolumeSnapshot: &cnpgv1.VolumeSnapshotConfiguration{
Class: backupSpec.VolumeSnapshotClass,
},
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix VolumeSnapshotConfiguration field name

cnpgv1.VolumeSnapshotConfiguration uses ClassName, not Class. Using Class will not compile against CNPG v1 APIs and misleads anyone implementing from this design. Please update the snippet to reference ClassName.

🤖 Prompt for AI Agents
In doc/design/noobaa-cnpg-db-backup.md around lines 190 to 194, the code snippet
sets VolumeSnapshot configuration using the non-existent field Class; update it
to use the correct CNPG v1 API field name ClassName instead. Replace the Class:
backupSpec.VolumeSnapshotClass entry with ClassName:
backupSpec.VolumeSnapshotClass so the snippet compiles against CNPG v1 and
accurately reflects the API.

Comment on lines +304 to +308
r.CNPGCluster.Spec.Bootstrap = &cnpgv1.BootstrapConfiguration{
Recovery: &cnpgv1.BootstrapRecovery{
Source: snapshotName,
},
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Correct BootstrapRecovery structure

cnpgv1.BootstrapRecovery does not accept a bare Source string for snapshot recovery. It expects the nested VolumeSnapshot field (with Name, optional Kind/APIGroup). Documenting Source here will produce invalid code/templates. Please revise the example to set VolumeSnapshot: &cnpgv1.VolumeSnapshotSource{Name: snapshotName} (and related fields as needed).

🤖 Prompt for AI Agents
In doc/design/noobaa-cnpg-db-backup.md around lines 304 to 308, the example sets
Recovery.Source to a bare string which is invalid; update the BootstrapRecovery
to populate the nested VolumeSnapshot field instead (e.g., VolumeSnapshot:
&cnpgv1.VolumeSnapshotSource{Name: snapshotName} and include Kind/APIGroup if
needed) so the structure matches the cnpgv1.BootstrapRecovery schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant