diff --git a/changelogs/unreleased/9864-Lyndon-Li b/changelogs/unreleased/9864-Lyndon-Li new file mode 100644 index 000000000..1d885de8f --- /dev/null +++ b/changelogs/unreleased/9864-Lyndon-Li @@ -0,0 +1 @@ +Add cbt service parameters to node-agent-config for block data mover \ No newline at end of file diff --git a/pkg/cmd/cli/nodeagent/server.go b/pkg/cmd/cli/nodeagent/server.go index bb1764cb3..374dbcac9 100644 --- a/pkg/cmd/cli/nodeagent/server.go +++ b/pkg/cmd/cli/nodeagent/server.go @@ -385,6 +385,12 @@ func (s *nodeAgentServer) run() { s.logger.Info("Backup repo config is not provided, using default values for cache volume configs") } + var csiSnapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService + if s.dataPathConfigs != nil && s.dataPathConfigs.CSISnapshotMetadataServiceConfigs != nil { + csiSnapshotMetadataServiceConfigs = s.dataPathConfigs.CSISnapshotMetadataServiceConfigs + s.logger.Infof("Using CSI snapshot metadata service config %v", s.dataPathConfigs.CSISnapshotMetadataServiceConfigs) + } + pvbReconciler := controller.NewPodVolumeBackupReconciler( s.mgr.GetClient(), s.mgr, @@ -447,6 +453,7 @@ func (s *nodeAgentServer) run() { dataMovePriorityClass, podLabels, podAnnotations, + csiSnapshotMetadataServiceConfigs, ) if err := dataUploadReconciler.SetupWithManager(s.mgr); err != nil { s.logger.WithError(err).Fatal("Unable to create the data upload controller") diff --git a/pkg/controller/data_upload_controller.go b/pkg/controller/data_upload_controller.go index 13be03994..d7248e7c3 100644 --- a/pkg/controller/data_upload_controller.go +++ b/pkg/controller/data_upload_controller.go @@ -66,25 +66,26 @@ const ( // DataUploadReconciler reconciles a DataUpload object type DataUploadReconciler struct { - client client.Client - kubeClient kubernetes.Interface - csiSnapshotClient snapshotter.SnapshotV1Interface - mgr manager.Manager - Clock clocks.WithTickerAndDelayedExecution - nodeName string - logger logrus.FieldLogger - snapshotExposerList map[velerov2alpha1api.SnapshotType]exposer.SnapshotExposer - dataPathMgr *datapath.Manager - vgdpCounter *exposer.VgdpCounter - loadAffinity []*kube.LoadAffinity - backupPVCConfig map[string]velerotypes.BackupPVC - podResources corev1api.ResourceRequirements - preparingTimeout time.Duration - metrics *metrics.ServerMetrics - cancelledDataUpload map[string]time.Time - dataMovePriorityClass string - podLabels map[string]string - podAnnotations map[string]string + client client.Client + kubeClient kubernetes.Interface + csiSnapshotClient snapshotter.SnapshotV1Interface + mgr manager.Manager + Clock clocks.WithTickerAndDelayedExecution + nodeName string + logger logrus.FieldLogger + snapshotExposerList map[velerov2alpha1api.SnapshotType]exposer.SnapshotExposer + dataPathMgr *datapath.Manager + vgdpCounter *exposer.VgdpCounter + loadAffinity []*kube.LoadAffinity + backupPVCConfig map[string]velerotypes.BackupPVC + podResources corev1api.ResourceRequirements + preparingTimeout time.Duration + metrics *metrics.ServerMetrics + cancelledDataUpload map[string]time.Time + dataMovePriorityClass string + podLabels map[string]string + podAnnotations map[string]string + snapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService } func NewDataUploadReconciler( @@ -105,6 +106,7 @@ func NewDataUploadReconciler( dataMovePriorityClass string, podLabels map[string]string, podAnnotations map[string]string, + snapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService, ) *DataUploadReconciler { return &DataUploadReconciler{ client: client, @@ -121,17 +123,18 @@ func NewDataUploadReconciler( log, ), }, - dataPathMgr: dataPathMgr, - vgdpCounter: counter, - loadAffinity: loadAffinity, - backupPVCConfig: backupPVCConfig, - podResources: podResources, - preparingTimeout: preparingTimeout, - metrics: metrics, - cancelledDataUpload: make(map[string]time.Time), - dataMovePriorityClass: dataMovePriorityClass, - podLabels: podLabels, - podAnnotations: podAnnotations, + dataPathMgr: dataPathMgr, + vgdpCounter: counter, + loadAffinity: loadAffinity, + backupPVCConfig: backupPVCConfig, + podResources: podResources, + preparingTimeout: preparingTimeout, + metrics: metrics, + cancelledDataUpload: make(map[string]time.Time), + dataMovePriorityClass: dataMovePriorityClass, + podLabels: podLabels, + podAnnotations: podAnnotations, + snapshotMetadataServiceConfigs: snapshotMetadataServiceConfigs, } } @@ -993,23 +996,24 @@ func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload } return &exposer.CSISnapshotExposeParam{ - SnapshotName: du.Spec.CSISnapshot.VolumeSnapshot, - SourceNamespace: du.Spec.SourceNamespace, - SourcePVCName: pvc.Name, - SourcePVName: pv.Name, - StorageClass: du.Spec.CSISnapshot.StorageClass, - HostingPodLabels: hostingPodLabels, - HostingPodAnnotations: hostingPodAnnotation, - HostingPodTolerations: hostingPodTolerations, - AccessMode: accessMode, - OperationTimeout: du.Spec.OperationTimeout.Duration, - ExposeTimeout: r.preparingTimeout, - VolumeSize: pvc.Spec.Resources.Requests[corev1api.ResourceStorage], - Affinity: r.loadAffinity, - BackupPVCConfig: r.backupPVCConfig, - Resources: r.podResources, - NodeOS: nodeOS, - PriorityClassName: r.dataMovePriorityClass, + SnapshotName: du.Spec.CSISnapshot.VolumeSnapshot, + SourceNamespace: du.Spec.SourceNamespace, + SourcePVCName: pvc.Name, + SourcePVName: pv.Name, + StorageClass: du.Spec.CSISnapshot.StorageClass, + HostingPodLabels: hostingPodLabels, + HostingPodAnnotations: hostingPodAnnotation, + HostingPodTolerations: hostingPodTolerations, + AccessMode: accessMode, + OperationTimeout: du.Spec.OperationTimeout.Duration, + ExposeTimeout: r.preparingTimeout, + VolumeSize: pvc.Spec.Resources.Requests[corev1api.ResourceStorage], + Affinity: r.loadAffinity, + BackupPVCConfig: r.backupPVCConfig, + Resources: r.podResources, + NodeOS: nodeOS, + PriorityClassName: r.dataMovePriorityClass, + SnapshotMetadataServiceConfigs: r.snapshotMetadataServiceConfigs, }, nil } diff --git a/pkg/controller/data_upload_controller_test.go b/pkg/controller/data_upload_controller_test.go index a73e3de94..e6d5474f3 100644 --- a/pkg/controller/data_upload_controller_test.go +++ b/pkg/controller/data_upload_controller_test.go @@ -251,6 +251,7 @@ func initDataUploaderReconcilerWithError(needError ...error) (*DataUploadReconci "", // dataMovePriorityClass nil, // podLabels nil, // podAnnotations + nil, ), nil } @@ -1513,6 +1514,7 @@ func TestDataUploadSetupExposeParam(t *testing.T) { "upload-priority", tt.args.customLabels, tt.args.customAnnotations, + nil, ) // Act diff --git a/pkg/exposer/csi_snapshot.go b/pkg/exposer/csi_snapshot.go index 079a4b527..de1bf83c8 100644 --- a/pkg/exposer/csi_snapshot.go +++ b/pkg/exposer/csi_snapshot.go @@ -93,6 +93,9 @@ type CSISnapshotExposeParam struct { // PriorityClassName is the priority class name for the data mover pod PriorityClassName string + + // SnapshotMetadataServiceConfigs is the config for CSI snapshot metadata service + SnapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService } // CSISnapshotExposeWaitParam define the input param for WaitExposed of CSI snapshots @@ -264,6 +267,7 @@ func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1api.O csiExposeParam.PriorityClassName, intoleratableNodes, volumeTopology, + csiExposeParam.SnapshotMetadataServiceConfigs, ) if err != nil { return errors.Wrap(err, "error to create backup pod") @@ -600,6 +604,7 @@ func (e *csiSnapshotExposer) createBackupPod( priorityClassName string, intoleratableNodes []string, volumeTopology *corev1api.NodeSelector, + csiSnapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService, ) (*corev1api.Pod, error) { podName := ownerObject.Name @@ -655,6 +660,12 @@ func (e *csiSnapshotExposer) createBackupPod( args = append(args, podInfo.logFormatArgs...) args = append(args, podInfo.logLevelArgs...) + if csiSnapshotMetadataServiceConfigs != nil { + if csiSnapshotMetadataServiceConfigs.SAName != "" { + args = append(args, fmt.Sprintf("--csi-snapshot-metadata-service-sa=%s", csiSnapshotMetadataServiceConfigs.SAName)) + } + } + if affinity == nil { affinity = &kube.LoadAffinity{} } diff --git a/pkg/exposer/csi_snapshot_priority_test.go b/pkg/exposer/csi_snapshot_priority_test.go index d1ffa4700..8c3086f76 100644 --- a/pkg/exposer/csi_snapshot_priority_test.go +++ b/pkg/exposer/csi_snapshot_priority_test.go @@ -155,6 +155,7 @@ func TestCreateBackupPodWithPriorityClass(t *testing.T) { tc.expectedPriorityClass, nil, nil, + nil, ) require.NoError(t, err, tc.description) @@ -241,6 +242,7 @@ func TestCreateBackupPodWithMissingConfigMap(t *testing.T) { "", // empty priority class since config map is missing nil, nil, + nil, ) // Should succeed even when config map is missing diff --git a/pkg/types/node_agent.go b/pkg/types/node_agent.go index f456bbf55..42fe06f58 100644 --- a/pkg/types/node_agent.go +++ b/pkg/types/node_agent.go @@ -74,6 +74,10 @@ type CachePVC struct { ResidentThresholdInMB int64 `json:"residentThresholdInMB,omitempty"` } +type CSISnapshotMetadataService struct { + SAName string `json:"saName,omitempty"` +} + type NodeAgentConfigs struct { // LoadConcurrency is the config for data path load concurrency per node. LoadConcurrency *LoadConcurrency `json:"loadConcurrency,omitempty"` @@ -104,4 +108,7 @@ type NodeAgentConfigs struct { // PodLabels are labels to be added to pods created by node-agent, i.e., data mover pods. PodLabels map[string]string `json:"podLabels,omitempty"` + + // CSISnapshotMetadataServiceConfigs is the config for CSI snapshot metadata service + CSISnapshotMetadataServiceConfigs *CSISnapshotMetadataService `json:"csiSnapshotMetadataServiceConfigs,omitempty"` }