Skip to content

Conversation

@lllamnyp
Copy link
Member

What this PR does

This PR introduces a bare-bones Job backup strategy API type and stubs out all the boilerplate for a new controller that will handle this strategy, as well as any others in the strategy.backups.cozystack.io API group.

Release note

[backups] Create stubs and minimal implmentations for controllers for
the strategy.backups.cozystack.io API group.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Dec 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/backup-jobdriver-api

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.

@dosubot dosubot bot added the enhancement New feature or request label Dec 12, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lllamnyp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for a new backup strategy mechanism within the Cozystack project. It establishes a new Kubernetes API type for defining Job-based backup strategies and sets up the essential boilerplate for a dedicated controller to manage these resources. The changes also include the necessary infrastructure for building, deploying, and configuring this new controller via a Helm chart, preparing the system for future implementation of the backup logic.

Highlights

  • New API Type for Job Backup Strategy: Introduced a new Kubernetes API type, Job, under strategy.backups.cozystack.io/v1alpha1, to define a backup strategy using a one-shot Job. This includes JobSpec for defining the Pod template and JobStatus for conditions.
  • New Backup Strategy Controller: Added a new controller, backupstrategy-controller, specifically designed to handle the strategy.backups.cozystack.io API group. The BackupJobStrategyReconciler is set up, though its Reconcile logic is currently a stub.
  • Controller Deployment and Configuration: Included a comprehensive Helm chart (packages/system/backupstrategy-controller) for deploying the new controller. This chart defines the Deployment, ServiceAccount, ClusterRole, ClusterRoleBinding, and CRD templates, along with a Makefile for image building and configuration in values.yaml.
  • Code Generation Updates: The hack/update-codegen.sh script was modified to correctly generate and move CRD YAMLs for the new strategy.backups.cozystack.io API group, ensuring that the API definitions are properly managed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR introduces the basic scaffolding for a new Job backup strategy controller. The changes include new API types, a stubbed controller, and the necessary Helm chart and build configurations. The overall structure is sound and follows established patterns. I've identified a few issues: a missing scheme registration in the controller's main entrypoint which could lead to runtime errors, an inconsistent name in the Helm chart, and an unnecessary RBAC permission. Addressing these points will improve the correctness and maintainability of the new controller.

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(backupsv1alpha1.AddToScheme(scheme))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The scheme for the new strategy.backups.cozystack.io API group is not being registered. The controller will need to interact with Job custom resources from this group. Without registering the scheme, the manager's client won't know how to handle these types, which will likely cause runtime errors.

Please add the scheme registration. You'll also need to add the corresponding import:

import (
    // ...
    backupstrategyv1alpha1 "github.com/cozystack/cozystack/api/backups/strategy/v1alpha1"
    // ...
)
Suggested change
utilruntime.Must(backupsv1alpha1.AddToScheme(scheme))
utilruntime.Must(backupsv1alpha1.AddToScheme(scheme))
utilruntime.Must(backupstrategyv1alpha1.AddToScheme(scheme))

@@ -0,0 +1,3 @@
apiVersion: v2
name: cozy-backup-controller
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The chart name cozy-backup-controller is inconsistent with other resources in this package, such as the deployment, service account, and Makefile NAME variable, which all use backupstrategy-controller. To improve consistency and clarity, please rename the chart.

name: backupstrategy-controller

resources: ["*"]
verbs: ["get", "list", "watch"]
- apiGroups: ["backups.cozystack.io"]
resources: ["backupjobs", "restorejobs"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This ClusterRole grants permissions for restorejobs. However, the controller being introduced only reconciles BackupJob objects and doesn't seem to interact with restorejobs. To adhere to the principle of least privilege, it's best to remove permissions that are not currently required.

  resources: ["backupjobs"]

## What this PR does

This PR introduces a bare-bones Job backup strategy API type and stubs
out all the boilerplate for a new controller that will handle this
strategy, as well as any others in the `strategy.backups.cozystack.io`
API group.

### Release note

```release-note
[backups] Create stubs and minimal implmentations for controllers for
the strategy.backups.cozystack.io API group.
```

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp force-pushed the feat/backup-jobdriver-api branch from 0bdf25a to ee2a34c Compare December 12, 2025 13:08
@lllamnyp lllamnyp mentioned this pull request Dec 12, 2025
19 tasks
Base automatically changed from feat/jobdriver-backups to main December 12, 2025 14:02
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 14, 2025
@lllamnyp lllamnyp merged commit 1f0b5ff into main Dec 15, 2025
24 checks passed
@lllamnyp lllamnyp deleted the feat/backup-jobdriver-api branch December 15, 2025 06:53
lllamnyp added a commit that referenced this pull request Jan 8, 2026
## What this PR does

This PR introduces a bare-bones Job backup strategy API type and stubs
out all the boilerplate for a new controller that will handle this
strategy, as well as any others in the `strategy.backups.cozystack.io`
API group.

### Release note

```release-note
[backups] Create stubs and minimal implmentations for controllers for
the strategy.backups.cozystack.io API group.
```

(cherry picked from commit 1f0b5ff)
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
kvaps added a commit that referenced this pull request Jan 16, 2026
…d backup system (#1867)

## What this PR does

Update changelog for v1.0.0-alpha.1 to include missing features:
- **Cozystack Operator**: New operator for Package and PackageSource
management (#1740, #1741, #1755, #1756, #1760, #1761)
- **Backup System**: Comprehensive backup functionality with Velero
integration (#1640, #1685, #1687, #1708, #1719, #1720, #1737, #1762)
- Add @androndo to contributors
- Update Full Changelog link to v0.38.0...v1.0.0-alpha.1

### Release note

```release-note
[docs] Update changelog for v1.0.0-alpha.1: add cozystack-operator and backup system
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants