Skip to content

fix: auto-assign default backup method when cluster backup method is empty#25

Merged
zijiren233 merged 3 commits into
labring:fix/v1.0.2from
im0x0ing:fix/backup-method
Apr 13, 2026
Merged

fix: auto-assign default backup method when cluster backup method is empty#25
zijiren233 merged 3 commits into
labring:fix/v1.0.2from
im0x0ing:fix/backup-method

Conversation

@im0x0ing

@im0x0ing im0x0ing commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

When spec.backup.method is not set, the controller now automatically infers and patches a default backup method based on the component's ServiceKind or ComponentDefinition name, falling back to the first known default method present in the BackupPolicy.

Port of fix from v0.9.3 (9b9afca) to v1.0.2

@cla-assistant

cla-assistant Bot commented Mar 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zijiren233

Copy link
Copy Markdown
Member

zijiren/kubeblocks:backup-method-1.0.2

Copilot AI 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.

Pull request overview

This PR updates the data-protection controller to automatically infer and persist a default spec.backup.method on a Cluster when it is empty, using the ComponentDefinition’s serviceKind or ComponentDefinition name (with fallback to known default methods).

Changes:

  • Add default backup method inference logic and patch the Cluster when spec.backup.method is empty.
  • Update backup schedule reconciliation to propagate patch errors (instead of ignoring them).
  • Add a controller test covering defaulting behavior when backup is enabled and the method is empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
controllers/dataprotection/backuppolicydriver_controller.go Infers and patches a default Cluster backup method when empty; updates merge flow to return errors; expands RBAC verbs.
controllers/dataprotection/backuppolicydriver_controller_test.go Adds a test asserting the Cluster backup method is defaulted and the schedule contains the defaulted method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controllers/dataprotection/backuppolicydriver_controller.go Outdated
Comment thread controllers/dataprotection/backuppolicydriver_controller.go

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

controllers/dataprotection/backuppolicydriver_controller.go:615

  • mergeClusterBackup now returns only an error, but it still contains logic to allocate a new BackupSchedule when the input backupSchedule is nil. Since the newly created schedule is not returned to the caller, any caller passing nil won’t be able to use it. Either remove this nil-creation branch (if impossible by design) or change the function contract (e.g., return the schedule) so the new object can be persisted by the caller.
	// there is no backup schedule created by backup policy template, so we need to
	// create a new backup schedule for cluster backup.
	if backupSchedule == nil {
		backupSchedule = &dpv1alpha1.BackupSchedule{
			ObjectMeta: metav1.ObjectMeta{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controllers/dataprotection/backuppolicydriver_controller.go
Comment thread controllers/dataprotection/backuppolicydriver_controller_test.go
im0x0ing and others added 3 commits April 13, 2026 15:54
…empty

  When `spec.backup.method` is not set, the controller now automatically
  infers and patches a default backup method based on the component's
  ServiceKind or ComponentDefinition name, falling back to the first
  known default method present in the BackupPolicy.

  Port of fix from v0.9.3 (9b9afca) to v1.0.2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@im0x0ing im0x0ing force-pushed the fix/backup-method branch from e072bf1 to 1365c27 Compare April 13, 2026 07:55
@zijiren233 zijiren233 merged commit 0035593 into labring:fix/v1.0.2 Apr 13, 2026
2 checks passed
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.

3 participants