@@ -26,8 +26,7 @@ import (
26
26
"k8s.io/apimachinery/pkg/api/resource"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
28
"k8s.io/apimachinery/pkg/types"
29
- "k8s.io/utils/pointer"
30
-
29
+ "k8s.io/utils/ptr"
31
30
"sigs.k8s.io/controller-runtime/pkg/client"
32
31
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
33
32
)
@@ -266,18 +265,16 @@ func (r *DPAReconciler) customizeVeleroDeployment(dpa *oadpv1alpha1.DataProtecti
266
265
})
267
266
268
267
if hasShortLivedCredentials {
269
- expirationSeconds := int64 (3600 )
270
268
veleroDeployment .Spec .Template .Spec .Volumes = append (veleroDeployment .Spec .Template .Spec .Volumes ,
271
269
corev1.Volume {
272
270
Name : "bound-sa-token" ,
273
271
VolumeSource : corev1.VolumeSource {
274
272
Projected : & corev1.ProjectedVolumeSource {
275
- DefaultMode : common .DefaultModePtr (),
276
273
Sources : []corev1.VolumeProjection {
277
274
{
278
275
ServiceAccountToken : & corev1.ServiceAccountTokenProjection {
279
276
Audience : "openshift" ,
280
- ExpirationSeconds : & expirationSeconds ,
277
+ ExpirationSeconds : ptr . To ( int64 ( 3600 )) ,
281
278
Path : "token" ,
282
279
},
283
280
},
@@ -398,18 +395,30 @@ func (r *DPAReconciler) customizeVeleroDeployment(dpa *oadpv1alpha1.DataProtecti
398
395
}
399
396
}
400
397
if veleroDeployment .Spec .RevisionHistoryLimit == nil {
401
- veleroDeployment .Spec .RevisionHistoryLimit = pointer . Int32 ( 10 )
398
+ veleroDeployment .Spec .RevisionHistoryLimit = ptr . To ( int32 ( 10 ) )
402
399
}
403
400
if veleroDeployment .Spec .ProgressDeadlineSeconds == nil {
404
- veleroDeployment .Spec .ProgressDeadlineSeconds = pointer . Int32 ( 600 )
401
+ veleroDeployment .Spec .ProgressDeadlineSeconds = ptr . To ( int32 ( 600 ) )
405
402
}
403
+ r .appendPluginSpecificSpecs (dpa , veleroDeployment , veleroContainer , providerNeedsDefaultCreds , hasCloudStorage )
406
404
setPodTemplateSpecDefaults (& veleroDeployment .Spec .Template )
407
- return r .appendPluginSpecificSpecs (dpa , veleroDeployment , veleroContainer , providerNeedsDefaultCreds , hasCloudStorage )
405
+ if configMapName , ok := dpa .Annotations [common .UnsupportedVeleroServerArgsAnnotation ]; ok {
406
+ if configMapName != "" {
407
+ unsupportedServerArgsCM := corev1.ConfigMap {}
408
+ if err := r .Get (r .Context , types.NamespacedName {Namespace : dpa .Namespace , Name : configMapName }, & unsupportedServerArgsCM ); err != nil {
409
+ return err
410
+ }
411
+ if err := common .ApplyUnsupportedServerArgsOverride (veleroContainer , unsupportedServerArgsCM , common .Velero ); err != nil {
412
+ return err
413
+ }
414
+ }
415
+ }
416
+
417
+ return nil
408
418
}
409
419
410
420
// add plugin specific specs to velero deployment
411
- func (r * DPAReconciler ) appendPluginSpecificSpecs (dpa * oadpv1alpha1.DataProtectionApplication , veleroDeployment * appsv1.Deployment , veleroContainer * corev1.Container , providerNeedsDefaultCreds map [string ]bool , hasCloudStorage bool ) error {
412
-
421
+ func (r * DPAReconciler ) appendPluginSpecificSpecs (dpa * oadpv1alpha1.DataProtectionApplication , veleroDeployment * appsv1.Deployment , veleroContainer * corev1.Container , providerNeedsDefaultCreds map [string ]bool , hasCloudStorage bool ) {
413
422
init_container_resources := veleroContainer .Resources
414
423
415
424
for _ , plugin := range dpa .Spec .Configuration .Velero .DefaultPlugins {
@@ -453,22 +462,20 @@ func (r *DPAReconciler) appendPluginSpecificSpecs(dpa *oadpv1alpha1.DataProtecti
453
462
// set default secret name to use
454
463
secretName := pluginSpecificMap .SecretName
455
464
// append plugin specific volume mounts
456
- if veleroContainer != nil {
457
- veleroContainer .VolumeMounts = append (
458
- veleroContainer .VolumeMounts ,
459
- corev1.VolumeMount {
460
- Name : secretName ,
461
- MountPath : pluginSpecificMap .MountPath ,
462
- })
463
-
464
- // append plugin specific env vars
465
- veleroContainer .Env = append (
466
- veleroContainer .Env ,
467
- corev1.EnvVar {
468
- Name : pluginSpecificMap .EnvCredentialsFile ,
469
- Value : pluginSpecificMap .MountPath + "/" + credentials .CloudFieldPath ,
470
- })
471
- }
465
+ veleroContainer .VolumeMounts = append (
466
+ veleroContainer .VolumeMounts ,
467
+ corev1.VolumeMount {
468
+ Name : secretName ,
469
+ MountPath : pluginSpecificMap .MountPath ,
470
+ })
471
+
472
+ // append plugin specific env vars
473
+ veleroContainer .Env = append (
474
+ veleroContainer .Env ,
475
+ corev1.EnvVar {
476
+ Name : pluginSpecificMap .EnvCredentialsFile ,
477
+ Value : pluginSpecificMap .MountPath + "/" + credentials .CloudFieldPath ,
478
+ })
472
479
473
480
// append plugin specific volumes
474
481
veleroDeployment .Spec .Template .Spec .Volumes = append (
@@ -477,8 +484,7 @@ func (r *DPAReconciler) appendPluginSpecificSpecs(dpa *oadpv1alpha1.DataProtecti
477
484
Name : secretName ,
478
485
VolumeSource : corev1.VolumeSource {
479
486
Secret : & corev1.SecretVolumeSource {
480
- SecretName : secretName ,
481
- DefaultMode : common .DefaultModePtr (),
487
+ SecretName : secretName ,
482
488
},
483
489
},
484
490
})
@@ -509,20 +515,6 @@ func (r *DPAReconciler) appendPluginSpecificSpecs(dpa *oadpv1alpha1.DataProtecti
509
515
})
510
516
}
511
517
}
512
-
513
- if configMapName , ok := dpa .Annotations [common .UnsupportedVeleroServerArgsAnnotation ]; ok {
514
- if configMapName != "" {
515
- unsupportedServerArgsCM := corev1.ConfigMap {}
516
- if err := r .Get (r .Context , types.NamespacedName {Namespace : dpa .Namespace , Name : configMapName }, & unsupportedServerArgsCM ); err != nil {
517
- return err
518
- }
519
- if err := common .ApplyUnsupportedServerArgsOverride (veleroContainer , unsupportedServerArgsCM , common .Velero ); err != nil {
520
- return err
521
- }
522
- }
523
- }
524
-
525
- return nil
526
518
}
527
519
528
520
func (r * DPAReconciler ) customizeVeleroContainer (dpa * oadpv1alpha1.DataProtectionApplication , veleroDeployment * appsv1.Deployment , veleroContainer * corev1.Container , hasShortLivedCredentials bool , prometheusPort * int ) error {
@@ -774,12 +766,10 @@ func (r DPAReconciler) noDefaultCredentials(dpa oadpv1alpha1.DataProtectionAppli
774
766
hasCloudStorage := false
775
767
if dpa .Spec .Configuration .Velero .NoDefaultBackupLocation {
776
768
needDefaultCred := false
777
-
778
769
if dpa .Spec .UnsupportedOverrides [oadpv1alpha1 .OperatorTypeKey ] == oadpv1alpha1 .OperatorTypeMTC {
779
770
// MTC requires default credentials
780
771
needDefaultCred = true
781
772
}
782
- // go through cloudprovider plugins and mark providerNeedsDefaultCreds to false
783
773
for _ , provider := range dpa .Spec .Configuration .Velero .DefaultPlugins {
784
774
if psf , ok := credentials .PluginSpecificFields [provider ]; ok && psf .IsCloudProvider {
785
775
providerNeedsDefaultCreds [psf .PluginName ] = needDefaultCred
0 commit comments