@@ -58,17 +58,6 @@ func boolPtr(b bool) *bool {
5858 return & b
5959}
6060
61- func ownerRefsFromBackupJob (backupJob * backupsv1alpha1.BackupJob ) []metav1.OwnerReference {
62- return []metav1.OwnerReference {
63- {
64- APIVersion : backupJob .APIVersion ,
65- Kind : backupJob .Kind ,
66- Name : backupJob .Name ,
67- UID : backupJob .UID ,
68- },
69- }
70- }
71-
7261func (r * BackupJobReconciler ) reconcileVelero (ctx context.Context , j * backupsv1alpha1.BackupJob ) (ctrl.Result , error ) {
7362 logger := log .FromContext (ctx )
7463 logger .Info ("reconciling Velero strategy" , "backupjob" , j .Name , "phase" , j .Status .Phase )
@@ -262,9 +251,12 @@ func (r *BackupJobReconciler) resolveBucketStorageRef(ctx context.Context, stora
262251
263252 // Step 4: Get the secret name from BucketAccess
264253 secretName , found , err := unstructured .NestedString (bucketAccess .Object , "spec" , "credentialsSecretName" )
265- if err != nil || ! found {
254+ if err != nil {
266255 return nil , fmt .Errorf ("failed to get credentialsSecretName from BucketAccess: %w" , err )
267256 }
257+ if ! found || secretName == "" {
258+ return nil , fmt .Errorf ("credentialsSecretName not found in BucketAccess %s" , bucketAccessKey .Name )
259+ }
268260
269261 // Step 5: Get the secret
270262 secret := & corev1.Secret {}
@@ -632,9 +624,17 @@ func (r *BackupJobReconciler) createBackupResource(ctx context.Context, backupJo
632624
633625 backup := & backupsv1alpha1.Backup {
634626 ObjectMeta : metav1.ObjectMeta {
635- Name : fmt .Sprintf ("%s-backup" , backupJob .Name ),
636- Namespace : backupJob .Namespace ,
637- OwnerReferences : ownerRefsFromBackupJob (backupJob ),
627+ Name : fmt .Sprintf ("%s-backup" , backupJob .Name ),
628+ Namespace : backupJob .Namespace ,
629+ OwnerReferences : []metav1.OwnerReference {
630+ {
631+ APIVersion : backupJob .APIVersion ,
632+ Kind : backupJob .Kind ,
633+ Name : backupJob .Name ,
634+ UID : backupJob .UID ,
635+ Controller : boolPtr (true ),
636+ },
637+ },
638638 },
639639 Spec : backupsv1alpha1.BackupSpec {
640640 ApplicationRef : backupJob .Spec .ApplicationRef ,
0 commit comments