Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/9602-sseago
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optimize VSC handle readiness polling for VSS backups
6 changes: 6 additions & 0 deletions config/crd/v1/bases/velero.io_backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ spec:
spec:
description: BackupSpec defines the specification for a Velero backup.
properties:
csiSnapshotEarlyFrequentPolling:
description: |-
CSISnapshotEarlyFrequentPolling specifies whether to use an early frequent polling for CSI VolumeSnapshot status turns to
ReadyToUse during creation.
nullable: true
type: boolean
csiSnapshotTimeout:
description: |-
CSISnapshotTimeout specifies the time used to wait for CSI VolumeSnapshot status turns to
Expand Down
6 changes: 6 additions & 0 deletions config/crd/v1/bases/velero.io_schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ spec:
Template is the definition of the Backup to be run
on the provided schedule
properties:
csiSnapshotEarlyFrequentPolling:
description: |-
CSISnapshotEarlyFrequentPolling specifies whether to use an early frequent polling for CSI VolumeSnapshot status turns to
ReadyToUse during creation.
nullable: true
type: boolean
csiSnapshotTimeout:
description: |-
CSISnapshotTimeout specifies the time used to wait for CSI VolumeSnapshot status turns to
Expand Down
4 changes: 2 additions & 2 deletions config/crd/v1/crds/crds.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pkg/apis/velero/v1/backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ type BackupSpec struct {
// +optional
CSISnapshotTimeout metav1.Duration `json:"csiSnapshotTimeout,omitempty"`

// CSISnapshotEarlyFrequentPolling specifies whether to use an early frequent polling for CSI VolumeSnapshot status turns to
// ReadyToUse during creation.
// +optional
// +nullable
CSISnapshotEarlyFrequentPolling *bool `json:"csiSnapshotEarlyFrequentPolling,omitempty"`

// ItemOperationTimeout specifies the time used to wait for asynchronous BackupItemAction operations
// The default value is 4 hour.
// +optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/velero/v1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions pkg/backup/actions/csi/pvc_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func (p *pvcBackupItemAction) Execute(
p.crClient,
p.log,
backup.Spec.CSISnapshotTimeout.Duration,
backup.Spec.CSISnapshotEarlyFrequentPolling,
)
if err != nil {
p.log.Errorf("Failed to wait for VolumeSnapshot %s/%s to become ReadyToUse within timeout %v: %s",
Expand Down
6 changes: 6 additions & 0 deletions pkg/builder/backup_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ func (b *BackupBuilder) CSISnapshotTimeout(timeout time.Duration) *BackupBuilder
return b
}

// CSISnapshotEarlyFrequentPolling sets the Backup's CSISnapshotEarlyFrequentPolling flag.
func (b *BackupBuilder) CSISnapshotEarlyFrequentPolling(val bool) *BackupBuilder {
b.object.Spec.CSISnapshotEarlyFrequentPolling = &val
return b
}

// ItemOperationTimeout sets the Backup's ItemOperationTimeout
func (b *BackupBuilder) ItemOperationTimeout(timeout time.Duration) *BackupBuilder {
b.object.Spec.ItemOperationTimeout.Duration = timeout
Expand Down
18 changes: 13 additions & 5 deletions pkg/cmd/cli/backup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type CreateOptions struct {
SnapshotMoveData flag.OptionalBool
DataMover string
DefaultVolumesToFsBackup flag.OptionalBool
CSISnapshotEarlyFrequentPolling flag.OptionalBool
IncludeNamespaces flag.StringArray
ExcludeNamespaces flag.StringArray
IncludeResources flag.StringArray
Expand Down Expand Up @@ -112,11 +113,12 @@ type CreateOptions struct {

func NewCreateOptions() *CreateOptions {
return &CreateOptions{
IncludeNamespaces: flag.NewStringArray("*"),
Labels: flag.NewMap(),
Annotations: flag.NewMap(),
SnapshotVolumes: flag.NewOptionalBool(nil),
IncludeClusterResources: flag.NewOptionalBool(nil),
IncludeNamespaces: flag.NewStringArray("*"),
Labels: flag.NewMap(),
Annotations: flag.NewMap(),
SnapshotVolumes: flag.NewOptionalBool(nil),
CSISnapshotEarlyFrequentPolling: flag.NewOptionalBool(nil),
IncludeClusterResources: flag.NewOptionalBool(nil),
}
}

Expand Down Expand Up @@ -153,6 +155,9 @@ func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) {
f = flags.VarPF(&o.DefaultVolumesToFsBackup, "default-volumes-to-fs-backup", "", "Use pod volume file system backup by default for volumes")
f.NoOptDefVal = cmd.TRUE

f = flags.VarPF(&o.CSISnapshotEarlyFrequentPolling, "csi-snapshot-early-frequent-polling", "", "Use early frequent polling for CSI snapshot creation by default for all CSI snapshots.")
f.NoOptDefVal = cmd.TRUE

flags.StringVar(&o.ResPoliciesConfigmap, "resource-policies-configmap", "", "Reference to the resource policies configmap that backup should use")
flags.StringVar(&o.DataMover, "data-mover", "", "Specify the data mover to be used by the backup. If the parameter is not set or set as 'velero', the built-in data mover will be used")
flags.IntVar(&o.ParallelFilesUpload, "parallel-files-upload", 0, "Number of files uploads simultaneously when running a backup. This is only applicable for the kopia uploader")
Expand Down Expand Up @@ -414,6 +419,9 @@ func (o *CreateOptions) BuildBackup(namespace string) (*velerov1api.Backup, erro
if o.DefaultVolumesToFsBackup.Value != nil {
backupBuilder.DefaultVolumesToFsBackup(*o.DefaultVolumesToFsBackup.Value)
}
if o.CSISnapshotEarlyFrequentPolling.Value != nil {
backupBuilder.CSISnapshotEarlyFrequentPolling(*o.CSISnapshotEarlyFrequentPolling.Value)
}
if o.ResPoliciesConfigmap != "" {
backupBuilder.ResourcePolicies(o.ResPoliciesConfigmap)
}
Expand Down
22 changes: 14 additions & 8 deletions pkg/cmd/cli/backup/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
cmdtest "github.com/vmware-tanzu/velero/pkg/cmd/test"
"github.com/vmware-tanzu/velero/pkg/test"
velerotest "github.com/vmware-tanzu/velero/pkg/test"
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
)

func TestCreateOptions_BuildBackup(t *testing.T) {
Expand All @@ -48,6 +49,7 @@ func TestCreateOptions_BuildBackup(t *testing.T) {
o.OrderedResources = "pods=p1,p2;persistentvolumeclaims=pvc1,pvc2"
orders, err := ParseOrderedResources(o.OrderedResources)
o.CSISnapshotTimeout = 20 * time.Minute
o.CSISnapshotEarlyFrequentPolling.Value = boolptr.True()
o.ItemOperationTimeout = 20 * time.Minute
orLabelSelectors := []*metav1.LabelSelector{
{
Expand All @@ -64,14 +66,15 @@ func TestCreateOptions_BuildBackup(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, velerov1api.BackupSpec{
TTL: metav1.Duration{Duration: o.TTL},
IncludedNamespaces: []string(o.IncludeNamespaces),
SnapshotVolumes: o.SnapshotVolumes.Value,
IncludeClusterResources: o.IncludeClusterResources.Value,
OrderedResources: orders,
OrLabelSelectors: orLabelSelectors,
CSISnapshotTimeout: metav1.Duration{Duration: o.CSISnapshotTimeout},
ItemOperationTimeout: metav1.Duration{Duration: o.ItemOperationTimeout},
TTL: metav1.Duration{Duration: o.TTL},
IncludedNamespaces: []string(o.IncludeNamespaces),
SnapshotVolumes: o.SnapshotVolumes.Value,
IncludeClusterResources: o.IncludeClusterResources.Value,
OrderedResources: orders,
OrLabelSelectors: orLabelSelectors,
CSISnapshotTimeout: metav1.Duration{Duration: o.CSISnapshotTimeout},
CSISnapshotEarlyFrequentPolling: o.CSISnapshotEarlyFrequentPolling.Value,
ItemOperationTimeout: metav1.Duration{Duration: o.ItemOperationTimeout},
}, backup.Spec)

assert.Equal(t, map[string]string{
Expand Down Expand Up @@ -223,6 +226,7 @@ func TestCreateCommand(t *testing.T) {
selector := "a=pod"
orderedResources := "pod=pod1,pod2,pod3"
csiSnapshotTimeout := "8m30s"
csiSnapshotEarlyFrequentPolling := "true"
itemOperationTimeout := "99h1m6s"
snapshotVolumes := "false"
snapshotMoveData := "true"
Expand Down Expand Up @@ -252,6 +256,7 @@ func TestCreateCommand(t *testing.T) {
flags.Parse([]string{"--selector", selector})
flags.Parse([]string{"--ordered-resources", orderedResources})
flags.Parse([]string{"--csi-snapshot-timeout", csiSnapshotTimeout})
flags.Parse([]string{"--csi-snapshot-early-frequent-polling", csiSnapshotEarlyFrequentPolling})
flags.Parse([]string{"--item-operation-timeout", itemOperationTimeout})
flags.Parse([]string{fmt.Sprintf("--snapshot-volumes=%s", snapshotVolumes)})
flags.Parse([]string{fmt.Sprintf("--snapshot-move-data=%s", snapshotMoveData)})
Expand Down Expand Up @@ -302,6 +307,7 @@ func TestCreateCommand(t *testing.T) {
require.Equal(t, selector, o.Selector.String())
require.Equal(t, orderedResources, o.OrderedResources)
require.Equal(t, csiSnapshotTimeout, o.CSISnapshotTimeout.String())
require.Equal(t, csiSnapshotEarlyFrequentPolling, o.CSISnapshotEarlyFrequentPolling.String())
require.Equal(t, itemOperationTimeout, o.ItemOperationTimeout.String())
require.Equal(t, snapshotVolumes, o.SnapshotVolumes.String())
require.Equal(t, snapshotMoveData, o.SnapshotMoveData.String())
Expand Down
24 changes: 14 additions & 10 deletions pkg/cmd/cli/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Options struct {
DefaultVolumesToFsBackup bool
UploaderType string
DefaultSnapshotMoveData bool
CSISnapshotEarlyFrequentPolling bool
DisableInformerCache bool
ScheduleSkipImmediately bool
PodResources kubeutil.PodResources
Expand Down Expand Up @@ -141,6 +142,7 @@ func (o *Options) BindFlags(flags *pflag.FlagSet) {
flags.BoolVar(&o.DefaultVolumesToFsBackup, "default-volumes-to-fs-backup", o.DefaultVolumesToFsBackup, "Bool flag to configure Velero server to use pod volume file system backup by default for all volumes on all backups. Optional.")
flags.StringVar(&o.UploaderType, "uploader-type", o.UploaderType, fmt.Sprintf("The type of uploader to transfer the data of pod volumes, supported value: '%s'", uploader.KopiaType))
flags.BoolVar(&o.DefaultSnapshotMoveData, "default-snapshot-move-data", o.DefaultSnapshotMoveData, "Bool flag to configure Velero server to move data by default for all snapshots supporting data movement. Optional.")
flags.BoolVar(&o.CSISnapshotEarlyFrequentPolling, "csi-snapshot-early-frequent-polling", o.CSISnapshotEarlyFrequentPolling, "Bool flag to configure Velero server to use early frequent polling by default for all CSI snapshots. Optional.")
flags.BoolVar(&o.DisableInformerCache, "disable-informer-cache", o.DisableInformerCache, "Disable informer cache for Get calls on restore. With this enabled, it will speed up restore in cases where there are backup resources which already exist in the cluster, but for very large clusters this will increase velero memory usage. Default is false (don't disable). Optional.")
flags.BoolVar(&o.ScheduleSkipImmediately, "schedule-skip-immediately", o.ScheduleSkipImmediately, "Skip the first scheduled backup immediately after creating a schedule. Default is false (don't skip).")
flags.BoolVar(&o.NodeAgentDisableHostPath, "node-agent-disable-host-path", o.NodeAgentDisableHostPath, "Don't mount the pod volume host path to node-agent. Optional. Pod volume host path mount is required by fs-backup but could be disabled for other backup methods.")
Expand Down Expand Up @@ -238,16 +240,17 @@ func NewInstallOptions() *Options {
NodeAgentPodCPULimit: install.DefaultNodeAgentPodCPULimit,
NodeAgentPodMemLimit: install.DefaultNodeAgentPodMemLimit,
// Default to creating a VSL unless we're told otherwise
UseVolumeSnapshots: true,
NoDefaultBackupLocation: false,
CRDsOnly: false,
DefaultVolumesToFsBackup: false,
UploaderType: uploader.KopiaType,
DefaultSnapshotMoveData: false,
DisableInformerCache: false,
ScheduleSkipImmediately: false,
kubeletRootDir: install.DefaultKubeletRootDir,
NodeAgentDisableHostPath: false,
UseVolumeSnapshots: true,
NoDefaultBackupLocation: false,
CRDsOnly: false,
DefaultVolumesToFsBackup: false,
UploaderType: uploader.KopiaType,
DefaultSnapshotMoveData: false,
CSISnapshotEarlyFrequentPolling: false,
DisableInformerCache: false,
ScheduleSkipImmediately: false,
kubeletRootDir: install.DefaultKubeletRootDir,
NodeAgentDisableHostPath: false,
}
}

Expand Down Expand Up @@ -324,6 +327,7 @@ func (o *Options) AsVeleroOptions() (*install.VeleroOptions, error) {
DefaultVolumesToFsBackup: o.DefaultVolumesToFsBackup,
UploaderType: o.UploaderType,
DefaultSnapshotMoveData: o.DefaultSnapshotMoveData,
CSISnapshotEarlyFrequentPolling: o.CSISnapshotEarlyFrequentPolling,
DisableInformerCache: o.DisableInformerCache,
ScheduleSkipImmediately: o.ScheduleSkipImmediately,
PodResources: o.PodResources,
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/schedule/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
DefaultVolumesToFsBackup: o.BackupOptions.DefaultVolumesToFsBackup.Value,
OrderedResources: orders,
CSISnapshotTimeout: metav1.Duration{Duration: o.BackupOptions.CSISnapshotTimeout},
CSISnapshotEarlyFrequentPolling: o.BackupOptions.CSISnapshotEarlyFrequentPolling.Value,
ItemOperationTimeout: metav1.Duration{Duration: o.BackupOptions.ItemOperationTimeout},
DataMover: o.BackupOptions.DataMover,
SnapshotMoveData: o.BackupOptions.SnapshotMoveData.Value,
Expand Down
Loading
Loading