NO-JIRA: Backup refactor#1615
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (14)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRemoves the scheduled backup server and its helpers/tests, switches retention handling to the v1alpha1 API enum, replaces hardcoded EtcdBackup CR construction with a YAML template decoder, and modernizes sorting and small controller utilities to use the slices package. ChangesBackup server removal
Request-backup: CR templating
Prune & controller refactors
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 10 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (10 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/cmd/request-backup/requestbackup.go (1)
153-153: 💤 Low valueUse a type assertion with ok check for defensive decoding.
The direct type assertion will panic if the decoded object isn't the expected type. While the template is controlled in-repo, a defensive check provides clearer error messages during development if the template is modified incorrectly.
♻️ Proposed fix
- etcdBackup := obj.(*operatorv1alpha1.EtcdBackup) + etcdBackup, ok := obj.(*operatorv1alpha1.EtcdBackup) + if !ok { + return fmt.Errorf("expected *operatorv1alpha1.EtcdBackup, got %T", obj) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/cmd/request-backup/requestbackup.go` at line 153, The direct type assertion "etcdBackup := obj.(*operatorv1alpha1.EtcdBackup)" can panic if decoding returns an unexpected type; change it to a safe comma-ok assertion (e.g., etcdBackup, ok := obj.(*operatorv1alpha1.EtcdBackup)) and handle the false branch by returning or logging a clear error describing the unexpected type (including the actual type of obj) so decoding failures surface safely in the code path that decodes into obj.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/cmd/prune-backups/prune.go`:
- Around line 78-82: The CLI default for retention type in NewPruneCommand is
set to the string "None", but Validate() now treats an empty RetentionType as
the "none" case, causing mismatch and "unknown retention type" errors; update
NewPruneCommand to use an empty string (or the appropriate zero-value constant)
as the default for the retention type flag so that RetentionType("") is passed
through and the switch in prune.go (using RetentionType(r.RetentionType)) hits
the case "" / no-op path. Locate the flag/default setup in NewPruneCommand and
change the default from "None" to "" (or backupv1alpha1.RetentionType(\"\")/zero
value) to align with Validate and the switch handling.
---
Nitpick comments:
In `@pkg/cmd/request-backup/requestbackup.go`:
- Line 153: The direct type assertion "etcdBackup :=
obj.(*operatorv1alpha1.EtcdBackup)" can panic if decoding returns an unexpected
type; change it to a safe comma-ok assertion (e.g., etcdBackup, ok :=
obj.(*operatorv1alpha1.EtcdBackup)) and handle the false branch by returning or
logging a clear error describing the unexpected type (including the actual type
of obj) so decoding failures surface safely in the code path that decodes into
obj.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 835369cd-1043-49b1-bf13-cae8c248be38
📒 Files selected for processing (13)
bindata/etcd/etcd-backup-cr.yamlcmd/cluster-etcd-operator/main.gopkg/backuphelpers/backupvars.gopkg/backuphelpers/backupvars_test.gopkg/cmd/backuprestore/backupserver.gopkg/cmd/backuprestore/backupserver_test.gopkg/cmd/prune-backups/prune.gopkg/cmd/prune-backups/prune_test.gopkg/cmd/request-backup/requestbackup.gopkg/etcdenvvar/envvarcontroller_test.gopkg/operator/backupcontroller/backupcontroller.gopkg/operator/periodicbackupcontroller/periodicbackupcontroller.gopkg/operator/targetconfigcontroller/targetconfigcontroller.go
💤 Files with no reviewable changes (5)
- pkg/cmd/backuprestore/backupserver.go
- pkg/backuphelpers/backupvars_test.go
- pkg/cmd/backuprestore/backupserver_test.go
- pkg/operator/targetconfigcontroller/targetconfigcontroller.go
- pkg/backuphelpers/backupvars.go
|
/jira refresh |
|
@dusk125: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/retest |
|
/cc @tjungblu |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retest-required |
|
@dusk125: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/lgtm |
and a bit of modernization
Summary by CodeRabbit
New Features
Chores
Tests