mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
## What this PR does Closes #5291. Two paths left a MariaDB dump and its `k8s.mariadb.com/Backup` behind after the dump cleanup from #5233. **A run that never completes.** When the operator Backup stays short of `Complete` past `mariadbDefaultBackupDeadline`, the BackupJob now deletes it (background propagation, so its Job goes too) before it marks itself `Failed`, and says so in the failure message. No Cozystack `Backup` is ever made of such a run, so nothing else deleted it, and while it stood its window had no end: `contestedMariaDBDump` counted it as a possible writer of every later dump of the application, and every later `Backup` was released with `ArtifactNotDeleted`. Deleting the Job also stops a run that is still going from uploading a dump nobody tracks. An operator Backup that is `Complete=True` on a reason the driver does not know has a bounded window and is kept, as before. The decision is made on the operator Backup read from the API server, not the cache. A run the operator has just marked complete or failed goes down the normal path and is not deleted. The delete carries the UID and resourceVersion that were read, so a run that completes between the read and the delete is not deleted either. Past the deadline no new run is created, so a pass that deleted the run and then failed to persist `Failed` does not start another one on retry. A delete the API server keeps refusing shows as `Ready=False/OperatorBackupDeleteFailed` on the BackupJob. The delete also removes the run's pod, so before it the controller copies what held the pod up into the failure message: an unschedulable pod, or a container that is waiting or has failed. The MariaDB driver's other failure exits take the same path: the MariaDB application was deleted, the MariaDB CR never came back, the strategy disappeared past its deadline, the strategy no longer renders, the applicationRef is rejected, or the run could not be created. Past the deadline, the run is taken from the API server listing and `ensureMariaDBBackup` is not called, so a cache that has not seen the run cannot cause a second one to be created. mariadb-operator leaves the run of a MariaDB that went away at `Complete=False` for good, so if the application was later recreated under the same name, that run used to contest every later dump. The deadline is still 30 minutes from `StartedAt`, but a dump that is still running at that point is now stopped instead of being left to finish outside Cozystack. **Namespace teardown.** mariadb-operator puts no finalizer on its `Backup`, so during teardown it is usually gone before the Cozystack `Backup` finalizer runs. When the operator Backup is not found, the cleanup now: - takes bucket, prefix and Secret references from the snapshot in `status.underlyingResources`; - goes on only for a recorded dump (`k8s.mariadb.com/dump-file`) on the platform bucket written with the projected platform Secret, reached with the platform credentials, which do not depend on the namespace; - keeps the dump, with a `Warning ArtifactNotDeleted`, when another operator Backup, finished or not, could have written it (the same `contestedMariaDBDump` check as before); - retries a failed delete through `retryMariaDBCleanup`, which releases the `Backup` once the namespace is terminating. The snapshot and the storage URI now record the storage the run was created with, whatever its kind, rather than the strategy as rendered when the run completed. A strategy edited during a run therefore cannot send the cleanup to the wrong place. The BackupJob looks for its run on the API server rather than in the cache, so a retry after a failed status write never starts a second run. A `Running` BackupJob never starts a run at all, and if its run is gone the job is failed. A `Backup` with no recorded dump, no snapshot, a dump on another bucket or written with the tenant's own Secret, or unreadable platform credentials is released with a `Warning`, as before. A missing operator CRD keeps the old release path. The platform-bucket check that `mariadbCleanupConnection` used is now `mariadbPlatformConnection`, shared by both paths. Its behaviour is unchanged. Not covered: - Operator Backups left behind by BackupJobs that failed before this change are still there, because terminal BackupJobs are not reconciled again. Deleting them by hand releases the dumps they hold. - Deleting a BackupJob that is still running leaves its operator Backup, which has no ownerRef and no finalizer. This was already the case and is not addressed here. - The driver-independent terminal exits in `backupjob_controller.go` (BackupClass resolution, credentials projection) still fail a BackupJob without looking at a MariaDB run. - A run that is stopped at the deadline after it has uploaded its dump leaves that dump untracked. No `Backup` is ever made of such a run. The other fail-safe cases listed in the issue (a `Restore` that never completes, the single `Backup` worker, non-204 DELETE responses, endpoint moves) are not addressed here. Tests: `go test ./internal/backupcontroller/...`. The deadline outcome table now also checks whether the operator Backup was deleted. New cleanup tests cover a missing operator Backup: the dump deleted with the platform credentials, already absent, contested by an unfinished run, a failed delete held for retry, and each case it cannot reach (volume storage, a recorded name that is not a dump, a snapshot of another kind). Deadline tests cover a retry after a failed status write, a cache that trails a completed run or misses a new one, a delete conditional on the run that was read, a refused delete, and the application or MariaDB going away mid-run. ### Screenshots N/A, no UI changes. ### Downstream repositories I checked the trigger map in `docs/agents/contributing.md` against the diff. The diff touches `internal/backupcontroller/mariadbstrategy_*.go` and their tests. It also adds a message helper in `internal/backupcontroller/backupjob_controller.go` and changes comments in `internal/backupcontroller/backup_controller.go` and `packages/system/backupstrategy-controller/templates/rbac.yaml`. No values, schemas, CRDs, RBAC rules, annotations or telemetry change. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(backups): MariaDB dumps are no longer left in the bucket when a backup run never completes or when a tenant namespace is deleted. A BackupJob that times out now deletes the operator Backup it gave up on, so that run no longer blocks the deletion of later dumps. A Backup whose operator Backup is already gone now deletes its recorded dump from the platform bucket using the platform credentials. A MariaDB backup run that has not completed 30 minutes after its BackupJob started is now stopped. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * MariaDB backup cleanup now removes a recorded dump from the platform bucket when its operator Backup is already gone, while leaving contested or insufficiently verified dumps untouched. * Failed dump deletions are retried, and cleanup reports when a dump is already absent. * Backup jobs are less likely to start duplicate runs during retries, and completed backups retain the storage configuration used by their run. * Failure handling preserves completed runs and includes operator-run completion details when available. * Backup jobs now recheck the operator Backup before failing on a deadline, helping account for runs that completed or failed in the meantime. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
312 lines
14 KiB
Go
312 lines
14 KiB
Go
package backupcontroller
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
"k8s.io/client-go/tools/record"
|
|
ctrl "sigs.k8s.io/controller-runtime"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
|
|
|
strategyv1alpha1 "github.com/cozystack/cozystack/api/backups/strategy/v1alpha1"
|
|
backupsv1alpha1 "github.com/cozystack/cozystack/api/backups/v1alpha1"
|
|
"github.com/cozystack/cozystack/internal/backupcontroller/cnpgtypes"
|
|
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
|
)
|
|
|
|
// backupFinalizer guards the strategy-specific side state owned by a Backup.
|
|
// Velero artifacts (the velero.io/Backup CR plus its data on the BSL) are the
|
|
// historical reason for the finalizer, but CNPG-strategy Backups also own
|
|
// side state (a postgresql.cnpg.io/Backup CR) that must be cleaned up here.
|
|
const backupFinalizer = "backups.cozystack.io/cleanup"
|
|
|
|
// legacyVeleroBackupFinalizer is the finalizer name used by previous releases
|
|
// before the cleanup path was generalized across strategies. We still
|
|
// recognise it on existing objects so upgrades complete without leaking
|
|
// finalizers, but new Backups are stamped with backupFinalizer instead.
|
|
const legacyVeleroBackupFinalizer = "backups.cozystack.io/cleanup-velero"
|
|
|
|
// BackupReconciler reconciles Backup objects.
|
|
// It manages a finalizer that ensures strategy-owned side state (Velero or
|
|
// CNPG) is deleted when the cozystack Backup resource is deleted.
|
|
type BackupReconciler struct {
|
|
client.Client
|
|
Scheme *runtime.Scheme
|
|
Recorder record.EventRecorder
|
|
// CredentialsConfig locates the platform backup credentials: the Job-based
|
|
// cleanups project them into the Backup's namespace, and the MariaDB
|
|
// cleanup reads them to reach the platform bucket.
|
|
CredentialsConfig BackupCredentialsConfig
|
|
// APIReader is the manager's uncached reader. The MariaDB cleanup lists
|
|
// the RestoreJobs and operator Restores of a Backup, and the operator
|
|
// Backups that may own its dump, through it: a restore that started
|
|
// before the delete, or a run that has already uploaded its dump, may
|
|
// not be in the cache yet. Wired in SetupWithManager.
|
|
APIReader client.Reader
|
|
|
|
// newS3ObjectLister and newS3ObjectRemover override the S3 client the
|
|
// MariaDB cleanup deletes a dump with; nil means a real minio client.
|
|
// Set by unit tests.
|
|
newS3ObjectLister func(conn s3Connection) (s3ObjectLister, error)
|
|
newS3ObjectRemover func(conn s3Connection) (s3ObjectRemover, error)
|
|
}
|
|
|
|
func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
|
logger := log.FromContext(ctx)
|
|
logger.V(1).Info("reconciling Backup", "namespace", req.Namespace, "name", req.Name)
|
|
|
|
backup := &backupsv1alpha1.Backup{}
|
|
if err := r.Get(ctx, types.NamespacedName{Namespace: req.Namespace, Name: req.Name}, backup); err != nil {
|
|
if apierrors.IsNotFound(err) {
|
|
return ctrl.Result{}, nil
|
|
}
|
|
return ctrl.Result{}, err
|
|
}
|
|
|
|
// Handle deletion: clean up strategy-specific side state.
|
|
if !backup.DeletionTimestamp.IsZero() {
|
|
if controllerutil.ContainsFinalizer(backup, backupFinalizer) ||
|
|
controllerutil.ContainsFinalizer(backup, legacyVeleroBackupFinalizer) {
|
|
res, err := r.cleanupOnDelete(ctx, backup)
|
|
if err != nil {
|
|
logger.Error(err, "failed to clean up strategy-owned side state")
|
|
return ctrl.Result{}, err
|
|
}
|
|
if res.Requeue || res.RequeueAfter > 0 {
|
|
// Cleanup is still in progress (the Rabbitmq delete Job has not
|
|
// finished); keep the finalizer and requeue so no object is
|
|
// orphaned.
|
|
return res, nil
|
|
}
|
|
|
|
controllerutil.RemoveFinalizer(backup, backupFinalizer)
|
|
controllerutil.RemoveFinalizer(backup, legacyVeleroBackupFinalizer)
|
|
if err := r.Update(ctx, backup); err != nil {
|
|
return ctrl.Result{}, err
|
|
}
|
|
logger.V(1).Info("removed finalizer and cleaned up side state", "backup", backup.Name)
|
|
}
|
|
return ctrl.Result{}, nil
|
|
}
|
|
|
|
// Ensure finalizer is present
|
|
if !controllerutil.ContainsFinalizer(backup, backupFinalizer) {
|
|
controllerutil.AddFinalizer(backup, backupFinalizer)
|
|
if err := r.Update(ctx, backup); err != nil {
|
|
return ctrl.Result{}, err
|
|
}
|
|
logger.V(1).Info("added finalizer to Backup", "backup", backup.Name)
|
|
}
|
|
|
|
return ctrl.Result{}, nil
|
|
}
|
|
|
|
// cleanupOnDelete dispatches deletion cleanup to the driver that produced
|
|
// the Backup's side state. Mirrors restorejob_controller's cleanupOnDelete
|
|
// pattern - each strategy knows what it created and how to undo it. Velero
|
|
// owns the velero.io/Backup CR plus archive data on the BSL; CNPG owns the
|
|
// postgresql.cnpg.io/Backup CR; Job owns nothing namespace-scoped.
|
|
// A non-zero ctrl.Result asks the caller to keep the finalizer and requeue -
|
|
// used by the Rabbitmq branch, which waits for its S3 delete Job to finish
|
|
// before letting the Backup be removed, so no object is orphaned.
|
|
func (r *BackupReconciler) cleanupOnDelete(ctx context.Context, backup *backupsv1alpha1.Backup) (ctrl.Result, error) {
|
|
logger := log.FromContext(ctx)
|
|
kind := strategyKindForBackup(backup)
|
|
logger.V(1).Info("dispatching Backup cleanup", "backup", backup.Name, "strategy", kind)
|
|
switch kind {
|
|
case strategyv1alpha1.CNPGStrategyKind:
|
|
return ctrl.Result{}, r.cleanupCNPGBackup(ctx, backup)
|
|
case strategyv1alpha1.JobStrategyKind:
|
|
// Nothing to clean up: Job-strategy Backups own no namespace-scoped
|
|
// artifacts that survive Backup deletion.
|
|
return ctrl.Result{}, nil
|
|
case strategyv1alpha1.AltinityStrategyKind:
|
|
// Cozystack Backup deletion does NOT purge the upstream
|
|
// clickhouse-backup archive in object storage. Lifecycle of the
|
|
// archive belongs to the clickhouse-backup tool inside the chi-*
|
|
// Pod (its retention config) or to manual purge through that
|
|
// tool's HTTP API (DELETE /backup/<name>/remote). Surfacing this
|
|
// as an explicit branch (rather than falling through to the
|
|
// Velero default) makes the contract obvious: the Altinity
|
|
// driver does not own the S3 data, so it does not delete it on
|
|
// CR removal. See packages/apps/clickhouse/README.md "Backup
|
|
// orchestration" for tenant-facing guidance.
|
|
return ctrl.Result{}, nil
|
|
case strategyv1alpha1.MariaDBStrategyKind:
|
|
// mariadb-operator's maxRetention prunes only from inside the next
|
|
// backup run of the same prefix and a Plan never deletes a Backup, so
|
|
// a dump on the platform bucket is deleted here or never. A dump in
|
|
// a tenant's own bucket is deleted too: the Backup proves it owns
|
|
// it, and tenants cannot delete Backups, so the delete comes from an
|
|
// administrator or from namespace teardown. Teardown can remove the
|
|
// operator Backup first; a recorded dump on the platform bucket is
|
|
// then still deleted, and any other is left behind with a Warning
|
|
// (see cleanupMariaDBBackup).
|
|
return r.cleanupMariaDBBackup(ctx, backup)
|
|
case strategyv1alpha1.MongoDBStrategyKind:
|
|
// Split by flow (see cleanupMongoDBBackup). A legacy backup writes to the
|
|
// tenant's own bucket and its lifecycle stays the tenant's / psmdb
|
|
// operator's — that branch is a no-op, the same "we do not own the
|
|
// archive" contract as Altinity / FDB. A useSystemBucket backup
|
|
// lands in the shared cozy-backups bucket with no psmdb task retention to
|
|
// prune it, so the driver OWNS it: this deletes the operator
|
|
// PerconaServerMongoDBBackup CR and waits for its delete-backup finalizer
|
|
// to free the object before the Backup is removed (like Redis / Rabbitmq).
|
|
return r.cleanupMongoDBBackup(ctx, backup)
|
|
case strategyv1alpha1.FoundationDBStrategyKind:
|
|
// Cozystack Backup deletion does NOT delete the operator-side
|
|
// foundationdb.org/FoundationDBBackup CR. That CR drives a
|
|
// continuously streaming backup_agent Deployment; its lifecycle
|
|
// is governed by the next BackupJob's stopOtherFoundationDBBackups
|
|
// call, by manual operator action, or by
|
|
// examples/backups/foundationdb/cleanup.sh. Same "we do not own
|
|
// the archive" contract as Altinity — the explicit
|
|
// branch guards the seam against a future driver refactor that
|
|
// might incidentally stamp velero.io/backup-name onto FDB
|
|
// driverMetadata via a shared helper.
|
|
return ctrl.Result{}, nil
|
|
case strategyv1alpha1.RabbitmqStrategyKind:
|
|
// Unlike the operator-backed drivers above, the Rabbitmq driver
|
|
// uniquely OWNS its artifact - a plain definitions object it wrote,
|
|
// with the exact key on status.artifact.uri - and no engine retention
|
|
// prunes it. Without an explicit delete a retention-pruned Plan would
|
|
// grow the bucket unboundedly, so this branch deletes the object and
|
|
// WAITS for that delete to complete before the Backup is removed, so no
|
|
// object is orphaned (see cleanupRabbitmqBackup).
|
|
return r.cleanupRabbitmqBackup(ctx, backup)
|
|
case strategyv1alpha1.RedisStrategyKind:
|
|
// Like Rabbitmq, the Redis driver OWNS its artifact - redisObjectKey
|
|
// mints one object per BackupJob and no engine retention prunes it - so
|
|
// this branch deletes that object and WAITS for the delete before the
|
|
// Backup is removed. Without it a retention-pruned Plan grows the bucket
|
|
// unboundedly and the key is lost with the CR (see cleanupRedisBackup).
|
|
return r.cleanupRedisBackup(ctx, backup)
|
|
case strategyv1alpha1.KafkaStrategyKind:
|
|
// Same property as Rabbitmq: the Kafka driver OWNS its artifact (a plain
|
|
// metadata object it wrote with curl, keyed on status.artifact.uri) and
|
|
// no engine retention prunes it. Without an explicit delete a
|
|
// retention-pruned Plan would grow the bucket unboundedly, so this branch
|
|
// deletes the object and WAITS for that delete before the Backup is
|
|
// removed, so no object is orphaned (see cleanupKafkaBackup).
|
|
return r.cleanupKafkaBackup(ctx, backup)
|
|
case strategyv1alpha1.KubernetesStrategyKind:
|
|
// Owns two artifacts: the Velero backup and the etcd dump object.
|
|
return r.cleanupKubernetesBackup(ctx, backup)
|
|
case strategyv1alpha1.VeleroStrategyKind:
|
|
return ctrl.Result{}, r.cleanupVeleroBackup(ctx, backup)
|
|
default:
|
|
// Unknown or empty strategy. Conservative path: try the Velero
|
|
// cleanup since it is keyed on a metadata field that only Velero
|
|
// sets, so it is a no-op for non-Velero Backups. This preserves
|
|
// backward compatibility with pre-existing objects.
|
|
return ctrl.Result{}, r.cleanupVeleroBackup(ctx, backup)
|
|
}
|
|
}
|
|
|
|
// strategyKindForBackup extracts the strategy kind from a Backup's
|
|
// strategyRef. Returns "" when the field is empty so callers can treat that
|
|
// as "unknown" and fall back to a safe default.
|
|
func strategyKindForBackup(backup *backupsv1alpha1.Backup) string {
|
|
return backup.Spec.StrategyRef.Kind
|
|
}
|
|
|
|
// cleanupVeleroBackup deletes the Velero backup and its data from storage
|
|
// by creating a Velero DeleteBackupRequest. A direct Delete of the
|
|
// backup.velero.io resource only removes the Kubernetes object; Velero's
|
|
// BSL sync will recreate it from the object store. The DeleteBackupRequest
|
|
// tells Velero to also purge the data, preventing resurrection.
|
|
func (r *BackupReconciler) cleanupVeleroBackup(ctx context.Context, backup *backupsv1alpha1.Backup) error {
|
|
logger := log.FromContext(ctx)
|
|
|
|
veleroBackupName, ok := backup.Spec.DriverMetadata[veleroBackupNameMetadataKey]
|
|
if !ok || veleroBackupName == "" {
|
|
logger.V(1).Info("no Velero backup name in driverMetadata, nothing to clean up")
|
|
return nil
|
|
}
|
|
|
|
veleroBackupNamespace := backup.Spec.DriverMetadata[veleroBackupNamespaceMetadataKey]
|
|
if veleroBackupNamespace == "" {
|
|
veleroBackupNamespace = veleroNamespace
|
|
}
|
|
|
|
// Check if the Velero Backup still exists
|
|
veleroBackup := &velerov1.Backup{}
|
|
err := r.Get(ctx, types.NamespacedName{
|
|
Namespace: veleroBackupNamespace,
|
|
Name: veleroBackupName,
|
|
}, veleroBackup)
|
|
if err != nil {
|
|
if apierrors.IsNotFound(err) {
|
|
logger.V(1).Info("Velero backup already deleted", "name", veleroBackupName)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("failed to get Velero backup %s/%s: %w", veleroBackupNamespace, veleroBackupName, err)
|
|
}
|
|
|
|
req, err := requestVeleroBackupDeletion(ctx, r.Client, veleroBackupNamespace, veleroBackupName, true)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if req.created {
|
|
logger.Info("created DeleteBackupRequest for Velero backup",
|
|
"name", veleroBackupName, "namespace", veleroBackupNamespace)
|
|
} else {
|
|
logger.V(1).Info("deletion of Velero backup already requested", "backup", veleroBackupName)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// cleanupCNPGBackup deletes the postgresql.cnpg.io/Backup CR that the CNPG
|
|
// driver created for this Cozystack Backup. It does NOT purge the Barman
|
|
// archive in S3 - CNPG itself does not expose a "delete this archive"
|
|
// surface, and removing only the CR matches the operator's expectation that
|
|
// archive lifecycle is governed by spec.backup.retentionPolicy on the
|
|
// Cluster. Tenants who need point-in-time deletion must do it through the
|
|
// object store directly.
|
|
func (r *BackupReconciler) cleanupCNPGBackup(ctx context.Context, backup *backupsv1alpha1.Backup) error {
|
|
logger := log.FromContext(ctx)
|
|
|
|
cnpgBackupName, ok := backup.Spec.DriverMetadata[cnpgBackupNameKey]
|
|
if !ok || cnpgBackupName == "" {
|
|
logger.V(1).Info("no cnpg.io backup name in driverMetadata, nothing to clean up")
|
|
return nil
|
|
}
|
|
|
|
cnpgBackup := &cnpgtypes.Backup{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Namespace: backup.Namespace,
|
|
Name: cnpgBackupName,
|
|
},
|
|
}
|
|
if err := r.Delete(ctx, cnpgBackup); err != nil && !apierrors.IsNotFound(err) {
|
|
return fmt.Errorf("failed to delete cnpg.io/Backup %s/%s: %w", backup.Namespace, cnpgBackupName, err)
|
|
}
|
|
logger.Info("deleted cnpg.io/Backup (or already absent)",
|
|
"name", cnpgBackupName, "namespace", backup.Namespace)
|
|
return nil
|
|
}
|
|
|
|
// SetupWithManager registers the BackupReconciler with the Manager.
|
|
func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
|
r.APIReader = mgr.GetAPIReader()
|
|
return ctrl.NewControllerManagedBy(mgr).
|
|
For(&backupsv1alpha1.Backup{}).
|
|
Complete(r)
|
|
}
|
|
|
|
// apiReader returns the uncached reader. Reconcilers built by hand in unit
|
|
// tests have none and fall back to their fake Client, which has no cache to
|
|
// bypass.
|
|
func (r *BackupReconciler) apiReader() client.Reader {
|
|
if r.APIReader != nil {
|
|
return r.APIReader
|
|
}
|
|
return r.Client
|
|
}
|