Skip to content

Commit 4c14004

Browse files
Fixing volume mount issue
Adding logic to ignore openshift & csi default plugins
1 parent c52481b commit 4c14004

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

controllers/velero.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ func (r *VeleroReconciler) ReconcileVeleroDeployment(log logr.Logger) (bool, err
264264
if err != nil {
265265
return err
266266
}
267-
268267
// update the Deployment template
269268
return r.buildVeleroDeployment(veleroDeployment, &velero)
270269
})
@@ -531,3 +530,38 @@ func (r *VeleroReconciler) getVeleroResourceReqs(velero *oadpv1alpha1.Velero) co
531530

532531
return ResourcesReqs
533532
}
533+
534+
// For later: Move this code into validator.go when more need for validation arises
535+
// TODO: if multiple default plugins exist, ensure we validate all of them.
536+
// Right now its sequential validation
537+
func (r *VeleroReconciler) ValidateVeleroDeployment(log logr.Logger) (bool, error) {
538+
velero := oadpv1alpha1.Velero{}
539+
if err := r.Get(r.Context, r.NamespacedName, &velero); err != nil {
540+
return false, err
541+
}
542+
543+
var secretName string
544+
var defaultPlugin oadpv1alpha1.DefaultPlugin
545+
for _, defaultPlugin = range velero.Spec.DefaultVeleroPlugins {
546+
switch defaultPlugin {
547+
case oadpv1alpha1.DefaultPluginAWS:
548+
secretName = VeleroAWSSecretName
549+
case oadpv1alpha1.DefaultPluginMicrosoftAzure:
550+
secretName = VeleroAzureSecretName
551+
case oadpv1alpha1.DefaultPluginGCP:
552+
secretName = VeleroGCPSecretName
553+
554+
}
555+
556+
if defaultPlugin != oadpv1alpha1.DefaultPluginOpenShift && defaultPlugin != oadpv1alpha1.DefaultPluginCSI {
557+
_, err := r.getProviderSecret(secretName)
558+
if err != nil {
559+
r.Log.Info(fmt.Sprintf("error validating %s provider secret: %s/%s", defaultPlugin, r.NamespacedName.Namespace, secretName))
560+
return false, err
561+
}
562+
563+
}
564+
565+
}
566+
return true, nil
567+
}

controllers/velero_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
2122
routev1 "github.com/openshift/api/route/v1"
2223
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
2324

@@ -73,13 +74,15 @@ func (r *VeleroReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
7374
// Set reconciler context + name
7475
r.Context = ctx
7576
r.NamespacedName = req.NamespacedName
76-
7777
velero := oadpv1alpha1.Velero{}
78+
7879
if err := r.Get(ctx, req.NamespacedName, &velero); err != nil {
7980
log.Error(err, "unable to fetch velero CR")
8081
return result, client.IgnoreNotFound(err)
8182
}
83+
8284
_, err := ReconcileBatch(r.Log,
85+
r.ValidateVeleroDeployment,
8386
r.ReconcileVeleroSecurityContextConstraint,
8487
r.ReconcileResticRestoreHelperConfig,
8588
r.ValidateBackupStorageLocations,
@@ -103,6 +106,7 @@ func (r *VeleroReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
103106
Message: err.Error(),
104107
},
105108
)
109+
106110
} else {
107111
apimeta.SetStatusCondition(&velero.Status.Conditions,
108112
metav1.Condition{

0 commit comments

Comments
 (0)