Skip to content

fix(backups): CI was broken after merge - #2762

Merged
Andrey Kolkov (androndo) merged 1 commit into
mainfrom
fix/ci-after-merge
May 28, 2026
Merged

Andrey Kolkov (androndo) merged 1 commit into
mainfrom
fix/ci-after-merge

Conversation

@androndo

@androndo Andrey Kolkov (androndo) commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Fix CI break root cause: internal/backupcontroller/jobstrategy_controller.go:138, :422 calls renderJobTemplate which no longer exists — the rebased commit cefbaad renamed it to renderAltinityTemplate in altinitystrategy_controller.go (per the codebase's per-strategy convention: renderCNPGTemplate, renderEtcdTemplate, renderFoundationDBTemplate) but didn't add the corresponding renderJobTemplate to the Job strategy file. PR #2716 was merged with this break — main is currently broken.

Screenshots

Release note

Summary by CodeRabbit

  • New Features
    • Enhanced backup and restore operations to support templated Pod configurations, allowing dynamic configuration rendering during Job reconciliation with application context and backup metadata.

Review Change Stack

@github-actions github-actions Bot added size/M This PR changes 30-99 lines, ignoring generated files area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug labels May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a new helper function renderJobTemplate to support Job backup/restore reconciliation. The function constructs a template context containing Application, Release metadata, Mode, and Parameters, conditionally injects Backup details when supplied, and renders a corev1.PodTemplateSpec using the internal template engine.

Changes

Job strategy template rendering helper

Layer / File(s) Summary
Template rendering helper
internal/backupcontroller/jobstrategy_controller.go
Imports the internal template package and introduces renderJobTemplate, which builds context from Application, Release, Mode, Parameters, and optional Backup details, then renders a Pod template spec.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A little helper hops into place,
Rendering templates with grace and style,
Context flows smooth from Backup to Backup,
Pod specs emerge where templates smile! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title states 'fix(backups): CI was broken after merge' but the actual change adds a new helper function renderJobTemplate for Job backup/restore reconciliation, not a fix for broken CI. Update the title to accurately reflect the change, such as 'feat(backups): add renderJobTemplate helper for Job backup/restore reconciliation' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-after-merge

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 restores missing template rendering logic for the job strategy controller that was lost during a previous rebase. By introducing a dedicated rendering entrypoint, the controller can now correctly process PodTemplateSpec configurations, ensuring consistency with other backup drivers in the system.

Highlights

  • Template Rendering Logic: Added the renderJobTemplate function to handle the processing of PodTemplateSpec through the repository's text/template engine.
  • Dependency Management: Imported the internal template package to support the new rendering functionality.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 (@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 the 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 counterproductive. You can react with 👍 and 👎 on Gemini (@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.

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. ↩

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the renderJobTemplate function in internal/backupcontroller/jobstrategy_controller.go. This function templates a strategy's PodTemplateSpec using the repository's text/template engine, exposing a context map that includes Application, Release, Mode, Parameters, and optionally Backup details (such as ApplicationRef). This mirrors the template rendering patterns used by other drivers like Altinity. I have no feedback to provide as there are no review comments.

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Actionable comments posted: 0

@androndo Andrey Kolkov (androndo) changed the title fix(backups): CI was broken on unittests fix(backups): CI was broken after merge May 28, 2026

@lllamnyp Timofei Larkin (lllamnyp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Scope of the change

Branch: fix/ci-after-merge (PR #2762) targeting main.

Single-file fix to internal/backupcontroller/jobstrategy_controller.go:

  • Adds an import of github.com/cozystack/cozystack/internal/template.
  • Adds a new package-level function renderJobTemplate(corev1.PodTemplateSpec, map[string]interface{}, releaseName, releaseNamespace, mode string, parameters map[string]string, *backupsv1alpha1.Backup) (*corev1.PodTemplateSpec, error).

No other files touched. The build is currently broken on main because two existing call sites at lines 186 and 470 reference renderJobTemplate, but the function with that name was renamed to renderAltinityTemplate in PR #2716 (commit f17ead3) and never re-introduced in the Job driver file. This PR restores the missing symbol by adding a per-driver renderer.

Correctness

  • The new renderJobTemplate body is byte-identical to renderAltinityTemplate in altinitystrategy_controller.go:108-148 except for the function name and the inline comment that cross-references the Altinity rationale. Both functions take the same signature, build the same ctxMap, optionally inject .Backup.ApplicationRef, and delegate to template.Template(&tmpl, ctxMap). The two call sites pass exactly the arguments this signature expects — strategy.Spec.Template (a corev1.PodTemplateSpec), an unstructured app map, release name/namespace, mode constant (jobStrategyModeBackup / jobStrategyModeRestore), resolved/round-tripped parameters, and nil or backup for the optional source-app context.
  • The sourceAPIGroup nil-deref guard for backup.Spec.ApplicationRef.APIGroup is preserved.
  • The pattern matches the comment's claim about per-driver render entrypoints: renderCNPGTemplate, renderEtcdTemplate, renderFoundationDBTemplate, renderAltinityTemplate each live in their own file. Caveat: the CNPG/Etcd/FoundationDB renderers take typed app objects (*postgresapp.Postgres etc.) and a different signature, so the "convention" is "each driver owns its render entrypoint," not "the signatures are the same." Job and Altinity happen to share a signature because both consume map[string]interface{} and corev1.PodTemplateSpec. That asymmetry isn't introduced by this PR — it's the existing shape — and the comment in the new function explicitly says "Mirrors renderAltinityTemplate." Not a blocker.

Build / test verification

  • go build ./... — clean.
  • go vet ./internal/backupcontroller/... — clean.
  • go test ./internal/backupcontroller/... — ok github.com/cozystack/cozystack/internal/backupcontroller 0.577s.

The existing tests in internal/backupcontroller/jobstrategy_controller_test.go (TestReconcileJob_CreatesBatchJob, TestReconcileJob_CompletesAndCreatesBackup, TestReconcileJob_FailsOnJobFailed, TestReconcileJob_FailsOnMissingStrategy, TestReconcileJobRestore_CreatesBatchJobInTargetNamespace, TestReconcileJobRestore_CompletesSucceeds, TestReconcileJob_FailsOnUnmappableKind, TestReconcileJobRestore_FailsOnUnmappableTargetKind) all exercise reconcileJob / reconcileJobRestore, which call renderJobTemplate. On broken main these tests fail to compile (and therefore fail to run) because renderJobTemplate is undefined. With this PR they compile and pass. In particular TestReconcileJob_CreatesBatchJob asserts --app=app-test --mode=backup --bucket=gen-bucket --replicas=3 in the rendered container args, which proves .Application (replicas=3 from the live app), .Parameters (bucketName=gen-bucket), .Release.Name, and .Mode all reach the template engine through this function. That is exactly the regression test for "renderJobTemplate exists and produces the documented context." No additional unit test is needed.

Cosmetic notes (not blockers)

  • The renderJobTemplate body duplicates renderAltinityTemplate byte-for-byte. A small follow-up could factor the shared rendering into a renderPodTemplateSpec helper that both Altinity and Job call into — neither file would lose anything: the per-driver entrypoint convention is satisfied by both files retaining their named wrapper. The duplication is acceptable in this PR because it is the minimum diff that unbreaks main; the consolidation can be a separate refactor. Recommended to track this as a follow-up issue.
  • The PR description says "PR #2716 was merged with this break — main is currently broken." This is accurate.

Documentation

No documentation references renderJobTemplate directly. The Job strategy is documented at examples/backups/... and at the driver level; the doc strings inside the new function correctly cross-reference renderAltinityTemplate and the per-driver naming convention. No doc drift introduced.

@androndo
Andrey Kolkov (androndo) merged commit 67ba252 into main May 28, 2026
15 of 16 checks passed
@androndo
Andrey Kolkov (androndo) deleted the fix/ci-after-merge branch May 28, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Issues or PRs related to storage (linstor, seaweedfs, bucket, velero, harbor) kind/bug Categorizes issue or PR as related to a bug size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants