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

fix: Velero server args organization #1535

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 193 additions & 2 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/openshift/oadp-operator/pkg/common"
"github.com/openshift/oadp-operator/pkg/velero/server"
)

// Conditions
Expand Down Expand Up @@ -68,6 +67,198 @@ const TechPreviewAck UnsupportedImageKey = "tech-preview-ack"

const OperatorTypeMTC = "mtc"

// VeleroServerArgs are the arguments that are passed to the Velero server
type VeleroServerArgs struct {
ServerFlags `json:",inline"`
GlobalFlags `json:",inline"`
}

// This package is used to store ServerConfig struct and note information about flags for velero server and how they are set.
// The options you can set in `velero server` is a combination of ServerConfig, featureFlagSet

// ServerConfig holds almost all the configuration for the Velero server.
// https://github.com/openshift/velero/blob/dd02df5cd5751263fce6d1ebd48ea11423b0cd16/pkg/cmd/server/server.go#L112-L129
// +kubebuilder:object:generate=true
type ServerFlags struct {
// pluginDir will be fixed to /plugins
// pluginDir

// The address to expose prometheus metrics
// +optional
MetricsAddress string `json:"metrics-address,omitempty"`
// defaultBackupLocation will be defined outside of server config in DataProtectionApplication
// defaultBackupLocation string

// How often (in nanoseconds) 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.
// +optional
BackupSyncPeriod *time.Duration `json:"backup-sync-period,omitempty"`
// How long (in nanoseconds) pod volume file system backups/restores should be allowed to run before timing out. (default is 4 hours)
// +optional
PodVolumeOperationTimeout *time.Duration `json:"fs-backup-timeout,omitempty"`
// How long (in nanoseconds) to wait on persistent volumes and namespaces to terminate during a restore before timing out.
// +optional
ResourceTerminatingTimeout *time.Duration `json:"terminating-resource-timeout,omitempty"`
// How long (in nanoseconds) to wait by default before backups can be garbage collected. (default is 720 hours)
// +optional
DefaultBackupTTL *time.Duration `json:"default-backup-ttl,omitempty"`
// How often (in nanoseconds) to verify if the storage is valid. Optional. Set this to `0` to disable sync. (default is 1 minute)
// +optional
StoreValidationFrequency *time.Duration `json:"store-validation-frequency,omitempty"`
// 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 securitycontextconstraints,customresourcedefinitions,klusterletconfigs.config.open-cluster-management.io,managedcluster.cluster.open-cluster-management.io,namespaces,roles,rolebindings,clusterrolebindings,klusterletaddonconfig.agent.open-cluster-management.io,managedclusteraddon.addon.open-cluster-management.io,storageclasses,volumesnapshotclass.snapshot.storage.k8s.io,volumesnapshotcontents.snapshot.storage.k8s.io,volumesnapshots.snapshot.storage.k8s.io,datauploads.velero.io,persistentvolumes,persistentvolumeclaims,serviceaccounts,secrets,configmaps,limitranges,pods,replicasets.apps,clusterclasses.cluster.x-k8s.io,endpoints,services,-,clusterbootstraps.run.tanzu.vmware.com,clusters.cluster.x-k8s.io,clusterresourcesets.addons.cluster.x-k8s.io)
// +optional
RestoreResourcePriorities string `json:"restore-resource-priorities,omitempty"`
// defaultVolumeSnapshotLocations will be defined outside of server config in DataProtectionApplication
// defaultVolumeSnapshotLocations map[string]string

// DEPRECATED: this flag will be removed in v2.0. Use read-only backup storage locations instead.
// +optional
// RestoreOnly *bool `json:"restore-only,omitempty"`

// 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
// +kubebuilder:validation:Enum=backup;backup-operations;backup-deletion;backup-finalizer;backup-sync;download-request;gc;backup-repo;restore;restore-operations;schedule;server-status-request
// +optional
DisabledControllers []string `json:"disabled-controllers,omitempty"`
// 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
// +optional
ClientQPS *string `json:"client-qps,omitempty"`
// Maximum number of requests by the server to the Kubernetes API in a short period of time.
// +optional
ClientBurst *int `json:"client-burst,omitempty"`
// Page size of requests by the server to the Kubernetes API when listing objects during a backup. Set to 0 to disable paging.
// +optional
ClientPageSize *int `json:"client-page-size,omitempty"`
// The address to expose the pprof profiler.
// +optional
ProfilerAddress string `json:"profiler-address,omitempty"`
// How often (in nanoseconds) to check status on backup/restore operations after backup/restore processing.
// +optional
ItemOperationSyncFrequency *time.Duration `json:"item-operation-sync-frequency,omitempty"`
// The format for log output. Valid values are text, json. (default text)
// +kubebuilder:validation:Enum=text;json
// +optional
FormatFlag string `json:"log-format,omitempty"`
// How often (in nanoseconds) 'maintain' is run for backup repositories by default.
// +optional
RepoMaintenanceFrequency *time.Duration `json:"default-repo-maintain-frequency,omitempty"`
// How often (in nanoseconds) garbage collection checks for expired backups. (default is 1 hour)
// +optional
GarbageCollectionFrequency *time.Duration `json:"garbage-collection-frequency,omitempty"`
// Backup all volumes with pod volume file system backup by default.
// +optional
DefaultVolumesToFsBackup *bool `json:"default-volumes-to-fs-backup,omitempty"`
// How long (in nanoseconds) to wait on asynchronous BackupItemActions and RestoreItemActions to complete before timing out. (default is 1 hour)
DefaultItemOperationTimeout *time.Duration `json:"default-item-operation-timeout,omitempty"`
// How long (in nanoseconds) to wait for resource processes which are not covered by other specific timeout parameters. (default is 10 minutes)
ResourceTimeout *time.Duration `json:"resource-timeout,omitempty"`
// Max concurrent connections number that Velero can create with kube-apiserver. Default is 30. (default 30)
MaxConcurrentK8SConnections *int `json:"max-concurrent-k8s-connections,omitempty"`
}

// GlobalFlags are flags that are defined across Velero CLI commands
type GlobalFlags struct {
// We use same namespace as DataProtectionApplication
// Namespace string `json:"namespace,omitempty"`

// Features is an existing field in DataProtectionApplication
// --kubebuilder:validation:Enum=EnableCSI;EnableAPIGroupVersions;EnableUploadProgress
// Features []VeleroFeatureFlag `json:"features,omitempty"`

// Show colored output in TTY
// +optional
Colorized *bool `json:"colorized,omitempty"`
// CACert is not a flag in velero server
LoggingFlags `json:",inline"`
}

// klog init flags from https://github.com/openshift/velero/blob/240b4e666fe15ef98defa2b51483fe87ac9996fb/pkg/cmd/velero/velero.go#L125
// LoggingFlags collects all the global state of the logging setup.
type LoggingFlags struct {
// 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.
// +optional
ToStderr *bool `json:"logtostderr,omitempty"` // The -logtostderr flag.
mateusoliveira43 marked this conversation as resolved.
Show resolved Hide resolved
// log to standard error as well as files (no effect when -logtostderr=true)
// +optional
AlsoToStderr *bool `json:"alsologtostderr,omitempty"` // The -alsologtostderr flag.

// 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)
// +optional
StderrThreshold *int `json:"stderrthreshold,omitempty"` // The -stderrthreshold flag.

// bufferCache maintains the free list. It uses its own mutex
// so buffers can be grabbed and printed to without holding the main lock,
// for better parallelization.
// bufferCache buffer.Buffers

// mu protects the remaining elements of this structure and is
// used to synchronize logging.
// mu sync.Mutex
// file holds writer for each of the log types.
// file [severity.NumSeverity]flushSyncWriter
// flushD holds a flushDaemon that frequently flushes log file buffers.
// flushD *flushDaemon
// flushInterval is the interval for periodic flushing. If zero,
// the global default will be used.
// flushInterval time.Duration
// pcs is used in V to avoid an allocation when computing the caller's PC.
// pcs [1]uintptr
// vmap is a cache of the V Level for each V() call site, identified by PC.
// It is wiped whenever the vmodule flag changes state.
// vmap map[uintptr]Level
// filterLength stores the length of the vmodule filter chain. If greater
// than zero, it means vmodule is enabled. It may be read safely
// using sync.LoadInt32, but is only modified under mu.
// filterLength int32
// traceLocation is the state of the -log_backtrace_at flag.

// when logging hits line file:N, emit a stack trace
// +optional
TraceLocation string `json:"log_backtrace_at,omitempty"`
// These flags are modified only under lock, although verbosity may be fetched
// safely using atomic.LoadInt32.

// comma-separated list of pattern=N settings for file-filtered logging
// +optional
Vmodule string `json:"vmodule,omitempty"` // The state of the -vmodule flag.
// number for the log level verbosity
// +optional
Verbosity *int `json:"v,omitempty"` // V logging level, the value of the -v flag/

// If non-empty, write log files in this directory (no effect when -logtostderr=true)
// +optional
LogDir string `json:"log_dir,omitempty"`

// If non-empty, use this log file (no effect when -logtostderr=true)
// +optional
LogFile string `json:"log_file,omitempty"`

// 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)
// +kubebuilder:validation:Minimum=0
// +optional
LogFileMaxSizeMB *int64 `json:"log_file_max_size,omitempty"`

// If true, avoid header prefixes in the log messages
// +optional
SkipHeaders *bool `json:"skip_headers,omitempty"`

// If true, avoid headers when opening log files (no effect when -logtostderr=true)
// +optional
SkipLogHeaders *bool `json:"skip_log_headers,omitempty"`

// If true, adds the file directory to the header of the log messages
// +optional
AddDirHeader *bool `json:"add_dir_header,omitempty"`

// If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
// +optional
OneOutput *bool `json:"one_output,omitempty"`

// If set, all output will be filtered through the filter.
// filter LogFilter
}

type VeleroConfig struct {
// featureFlags defines the list of features to enable for Velero instance
// +optional
Expand Down Expand Up @@ -117,7 +308,7 @@ type VeleroConfig struct {
ClientQPS *int `json:"client-qps,omitempty"`
// Velero args are settings to customize velero server arguments. Overrides values in other fields.
// +optional
Args *server.Args `json:"args,omitempty"`
Args *VeleroServerArgs `json:"args,omitempty"`
}

// PodConfig defines the pod configuration options
Expand Down
Loading