Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OADP-1941: Default datamover SC and add mover annotation #1058

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ type VolumeOptions struct {
// cacheAccessMode is the access mode to be used to provision the cache volume
//+optional
CacheAccessMode string `json:"cacheAccessMode,omitempty"`
// moverSecurityContext allows enabling the PodSecurityContext used in
// the application pod(s); default value is true
//+optional
MoverSecurityContext *bool `json:"moverSecurityContext,omitempty"`
}

// Features defines the configuration for the DPA to enable the tech preview features
Expand Down
9 changes: 2 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,6 @@ spec:
cacheStorageClassName:
description: cacheStorageClassName is the storageClass that should be used when provisioning the data mover cache volume
type: string
moverSecurityContext:
description: moverSecurityContext allows enabling the PodSecurityContext used in the application pod(s); default value is true
type: boolean
storageClassName:
description: storageClassName can be used to override the StorageClass of the source or destination PVC
type: string
Expand All @@ -757,9 +754,6 @@ spec:
cacheStorageClassName:
description: cacheStorageClassName is the storageClass that should be used when provisioning the data mover cache volume
type: string
moverSecurityContext:
description: moverSecurityContext allows enabling the PodSecurityContext used in the application pod(s); default value is true
type: boolean
storageClassName:
description: storageClassName can be used to override the StorageClass of the source or destination PVC
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,6 @@ spec:
cacheStorageClassName:
description: cacheStorageClassName is the storageClass that should be used when provisioning the data mover cache volume
type: string
moverSecurityContext:
description: moverSecurityContext allows enabling the PodSecurityContext used in the application pod(s); default value is true
type: boolean
storageClassName:
description: storageClassName can be used to override the StorageClass of the source or destination PVC
type: string
Expand All @@ -757,9 +754,6 @@ spec:
cacheStorageClassName:
description: cacheStorageClassName is the storageClass that should be used when provisioning the data mover cache volume
type: string
moverSecurityContext:
description: moverSecurityContext allows enabling the PodSecurityContext used in the application pod(s); default value is true
type: boolean
storageClassName:
description: storageClassName can be used to override the StorageClass of the source or destination PVC
type: string
Expand Down
46 changes: 30 additions & 16 deletions controllers/datamover.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -91,6 +90,17 @@ func (r *DPAReconciler) ReconcileDataMoverController(log logr.Logger) (bool, err

return false, err
}

adpNS := corev1.Namespace{}
if err := r.Get(r.Context, types.NamespacedName{Name: r.NamespacedName.Namespace}, &adpNS); err != nil {
return false, err
}

// add volsync privileged mover annotation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

err = r.addAnnotations(&adpNS, r.Log)
if err != nil {
return false, err
}
}

dataMoverDeployment := &appsv1.Deployment{
Expand Down Expand Up @@ -749,7 +759,7 @@ func (r *DPAReconciler) buildDataMoverConfigMap(dpa *oadpv1alpha1.DataProtection
return fmt.Errorf("DPA CR cannot be nil")
}
if cm == nil {
return fmt.Errorf("datamover deployment cannot be nil")
return fmt.Errorf("datamover configmap cannot be nil")
}

cmMap := map[string]string{}
Expand All @@ -776,13 +786,7 @@ func (r *DPAReconciler) buildDataMoverConfigMap(dpa *oadpv1alpha1.DataProtection
if len(sourceOptions.CacheCapacity) > 0 {
cmMap["SourceCacheCapacity"] = sourceOptions.CacheCapacity
}
if sourceOptions.MoverSecurityContext != nil {
cmMap["SourceMoverSecurityContext"] = strconv.FormatBool(*sourceOptions.MoverSecurityContext)

// default to true
} else {
cmMap["SourceMoverSecurityContext"] = "true"
}
}

// check for destination volume options
Expand All @@ -808,14 +812,6 @@ func (r *DPAReconciler) buildDataMoverConfigMap(dpa *oadpv1alpha1.DataProtection
if len(destinationOptions.CacheCapacity) > 0 {
cmMap["DestinationCacheCapacity"] = destinationOptions.CacheCapacity
}

if destinationOptions.MoverSecurityContext != nil {
cmMap["DestinationMoverSecurityContext"] = strconv.FormatBool(*destinationOptions.MoverSecurityContext)

// default to true
} else {
cmMap["DestinationMoverSecurityContext"] = "true"
}
}

// check for SnapshotRetainPolicy parameters
Expand Down Expand Up @@ -917,3 +913,21 @@ func (r *DPAReconciler) parseGCPSecret(secret corev1.Secret, secretKey string) (

return gcpcreds, nil
}

func (r *DPAReconciler) addAnnotations(ns *corev1.Namespace, log logr.Logger) error {

annotations := ns.ObjectMeta.GetAnnotations()
if ns.ObjectMeta.Annotations == nil {
annotations = map[string]string{}
}

annotations[common.VolsyncPrivilegedAnnotation] = "true"
ns.ObjectMeta.SetAnnotations(annotations)

err := r.Update(r.Context, ns, &client.UpdateOptions{})
if err != nil {
return err
}

return nil
}
1 change: 1 addition & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
OADPOperatorServiceAccount = "openshift-adp-controller-manager"
VolSyncDeploymentName = "volsync-controller-manager"
VolSyncDeploymentNamespace = "openshift-operators"
VolsyncPrivilegedAnnotation = "volsync.backube/privileged-movers"
)

// Images
Expand Down