Skip to content

Commit

Permalink
master: OADP-1182 - Velero server args in DPA (#1016)
Browse files Browse the repository at this point in the history
* oadp-1.1: OADP-1557 Add all velero server args supported to DPA (#987)

* refactor: remove reconciler from functions

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* oadp-1.1: go get openshift/velero:oadp-1.1

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* add server package for velero server options

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* wip

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* replace apimachinery to avoid velero update

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* Delete util.go

* use `base := make(map[T]T)`

* Update go.mod, remove todo comment.

* Revert "use `base := make(map[T]T)`"

This reverts commit 0b9042a.

* controllers: add debugMode

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* add metrics port parsing error

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* simplified range expression

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* rely on remove duplicate at the end of the function

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* Apply suggestions from code review

---------

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* oadp-1.2 changes.

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* Use 4h for fs-backup-timeout

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>

* use oadp restic default timeout of 1h

---------

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
  • Loading branch information
kaovilai committed May 18, 2023
1 parent 410c2cc commit 5a70983
Show file tree
Hide file tree
Showing 23 changed files with 1,963 additions and 3,035 deletions.
45 changes: 45 additions & 0 deletions api/v1alpha1/oadp_types.go
Expand Up @@ -17,6 +17,10 @@ limitations under the License.
package v1alpha1

import (
"time"

"github.com/openshift/oadp-operator/pkg/common"
"github.com/openshift/oadp-operator/pkg/velero/server"
velero "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -97,6 +101,9 @@ type VeleroConfig struct {
// Default is 10m
// +optional
ResourceTimeout string `json:"resourceTimeout,omitempty"`
// Velero args are settings to customize velero server arguments. Overrides values in other fields.
// +optional
Args *server.Args `json:"args,omitempty"`
}

// PodConfig defines the pod configuration options
Expand Down Expand Up @@ -356,3 +363,41 @@ func (veleroConfig *VeleroConfig) HasFeatureFlag(flag string) bool {
func init() {
SchemeBuilder.Register(&DataProtectionApplication{}, &DataProtectionApplicationList{}, &CloudStorage{}, &CloudStorageList{})
}

// AutoCorrect is a collection of auto-correction functions for the DPA CR
// These auto corrects are in-memory only and do not persist to the CR
// There should not be another place where these auto-corrects are done
func (dpa *DataProtectionApplication) AutoCorrect() {
//check if CSI plugin is added in spec
if hasCSIPlugin(dpa.Spec.Configuration.Velero.DefaultPlugins) {
dpa.Spec.Configuration.Velero.FeatureFlags = append(dpa.Spec.Configuration.Velero.FeatureFlags, velero.CSIFeatureFlag)
}
if dpa.Spec.Configuration.Velero.RestoreResourcesVersionPriority != "" {
// if the RestoreResourcesVersionPriority is specified then ensure feature flag is enabled for enableApiGroupVersions
// duplicate feature flag checks are done in ReconcileVeleroDeployment
dpa.Spec.Configuration.Velero.FeatureFlags = append(dpa.Spec.Configuration.Velero.FeatureFlags, velero.APIGroupVersionsFeatureFlag)
}
if dpa.Spec.Configuration.Velero.Args != nil {
// if args is not nil, we take care of some fields that will be overridden from dpa if not specified in args
// Enable user to specify --fs-backup-timeout duration (OADP default 1h0m0s)
resticTimeout := "1h"
if dpa.Spec.Configuration != nil && dpa.Spec.Configuration.Restic != nil && len(dpa.Spec.Configuration.Restic.Timeout) > 0 {
resticTimeout = dpa.Spec.Configuration.Restic.Timeout
}
if pvOperationTimeout, err := time.ParseDuration(resticTimeout); err == nil && dpa.Spec.Configuration.Velero.Args.PodVolumeOperationTimeout == nil {
dpa.Spec.Configuration.Velero.Args.PodVolumeOperationTimeout = &pvOperationTimeout
}
}
dpa.Spec.Configuration.Velero.DefaultPlugins = common.RemoveDuplicateValues(dpa.Spec.Configuration.Velero.DefaultPlugins)
dpa.Spec.Configuration.Velero.FeatureFlags = common.RemoveDuplicateValues(dpa.Spec.Configuration.Velero.FeatureFlags)
}

func hasCSIPlugin(plugins []DefaultPlugin) bool {
for _, plugin := range plugins {
if plugin == DefaultPluginCSI {
// CSI plugin is added so ensure that CSI feature flags is set
return true
}
}
return false
}
6 changes: 6 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

136 changes: 136 additions & 0 deletions bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml
Expand Up @@ -311,6 +311,142 @@ spec:
type: object
velero:
properties:
args:
description: Velero args are settings to customize velero server arguments. Overrides values in other fields.
properties:
add_dir_header:
description: If true, adds the file directory to the header of the log messages
type: boolean
alsologtostderr:
description: log to standard error as well as files (no effect when -logtostderr=true)
type: boolean
backup-sync-period:
description: How often to ensure all Velero backups in object storage exist as Backup API objects in the cluster. This is the default sync period if none is explicitly specified for a backup storage location.
format: int64
type: integer
client-burst:
description: Maximum number of requests by the server to the Kubernetes API in a short period of time.
type: integer
client-page-size:
description: Page size of requests by the server to the Kubernetes API when listing objects during a backup. Set to 0 to disable paging.
type: integer
client-qps:
description: Maximum number of requests per second by the server to the Kubernetes API once the burst limit has been reached. this will be validated as a valid float32
type: string
colorized:
description: Show colored output in TTY
type: boolean
default-backup-ttl:
description: default 720h0m0s
format: int64
type: integer
default-item-operation-timeout:
description: How long to wait on asynchronous BackupItemActions and RestoreItemActions to complete before timing out. (default 1h0m0s)
format: int64
type: integer
default-repo-maintain-frequency:
description: How often 'maintain' is run for backup repositories by default.
format: int64
type: integer
default-volumes-to-fs-backup:
description: Backup all volumes with pod volume file system backup by default.
type: boolean
disabled-controllers:
description: List of controllers to disable on startup. Valid values are backup,backup-operations,backup-deletion,backup-finalizer,backup-sync,download-request,gc,backup-repo,restore,restore-operations,schedule,server-status-request
enum:
- backup
- backup-operations
- backup-deletion
- backup-finalizer
- backup-sync
- download-request
- gc
- backup-repo
- restore
- restore-operations
- schedule
- server-status-request
items:
type: string
type: array
fs-backup-timeout:
description: How long pod volume file system backups/restores should be allowed to run before timing out. (default 4h0m0s)
format: int64
type: integer
garbage-collection-frequency:
description: How long to wait by default before backups can be garbage collected. (default 720h0m0s)
format: int64
type: integer
item-operation-sync-frequency:
description: How often to check status on backup/restore operations after backup/restore processing.
format: int64
type: integer
log-format:
description: The format for log output. Valid values are text, json. (default text)
enum:
- text
- json
type: string
log_backtrace_at:
description: when logging hits line file:N, emit a stack trace
type: string
log_dir:
description: If non-empty, write log files in this directory (no effect when -logtostderr=true)
type: string
log_file:
description: If non-empty, use this log file (no effect when -logtostderr=true)
type: string
log_file_max_size:
description: Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
format: int64
minimum: 0
type: integer
logtostderr:
description: 'Boolean flags. Not handled atomically because the flag.Value interface does not let us avoid the =true, and that shorthand is necessary for compatibility. TODO: does this matter enough to fix? Seems unlikely.'
type: boolean
max-concurrent-k8s-connections:
description: Max concurrent connections number that Velero can create with kube-apiserver. Default is 30. (default 30)
type: integer
metrics-address:
description: The address to expose prometheus metrics
type: string
one_output:
description: If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
type: boolean
profiler-address:
description: The address to expose the pprof profiler.
type: string
resource-timeout:
description: How long to wait for resource processes which are not covered by other specific timeout parameters. Default is 10 minutes. (default 10m0s)
format: int64
type: integer
restore-resource-priorities:
description: Desired order of resource restores, the priority list contains two parts which are split by "-" element. The resources before "-" element are restored first as high priorities, the resources after "-" element are restored last as low priorities, and any resource not in the list will be restored alphabetically between the high and low priorities. (default customresourcedefinitions,namespaces,storageclasses,volumesnapshotbackups.datamover.oadp.openshift.io,volumesnapshotclass.snapshot.storage.k8s.io,volumesnapshotcontents.snapshot.storage.k8s.io,volumesnapshots.snapshot.storage.k8s.io,persistentvolumes,persistentvolumeclaims,serviceaccounts,secrets,configmaps,limitranges,pods,replicasets.apps,clusterclasses.cluster.x-k8s.io,services,-,clusterbootstraps.run.tanzu.vmware.com,clusters.cluster.x-k8s.io,clusterresourcesets.addons.cluster.x-k8s.io)
type: string
skip_headers:
description: If true, avoid header prefixes in the log messages
type: boolean
skip_log_headers:
description: If true, avoid headers when opening log files (no effect when -logtostderr=true)
type: boolean
stderrthreshold:
description: logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
type: integer
store-validation-frequency:
description: How often to verify if the storage is valid. Optional. Set this to `0s` to disable sync. Default 1 minute.
format: int64
type: integer
terminating-resource-timeout:
description: How long to wait on persistent volumes and namespaces to terminate during a restore before timing out.
format: int64
type: integer
v:
description: number for the log level verbosity
type: integer
vmodule:
description: comma-separated list of pattern=N settings for file-filtered logging
type: string
type: object
customPlugins:
description: customPlugins defines the custom plugin to be installed with Velero
items:
Expand Down

0 comments on commit 5a70983

Please sign in to comment.