Skip to content
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
67 changes: 52 additions & 15 deletions api/v1alpha1/dataprotectionapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,33 @@ type NodeAgentCommonFields struct {
PodConfig *PodConfig `json:"podConfig,omitempty"`
}

type RestorePVC struct {
// IgnoreDelayBinding indicates to ignore delay binding the restorePVC when it is in WaitForFirstConsumer mode
IgnoreDelayBinding bool `json:"ignoreDelayBinding,omitempty"`
// Below struct should be same as:
// https://github.com/openshift/velero/blob/584cf1148a746838ee67aa27e3e4e0ded1f5c069/pkg/nodeagent/node_agent.go#L52-L58

// LoadConcurrency is the config for data path load concurrency per node.
type LoadConcurrency struct {
// GlobalConfig specifies the concurrency number to all nodes for which per-node config is not specified
GlobalConfig int `json:"globalConfig,omitempty"`

// PerNodeConfig specifies the concurrency number to nodes matched by rules
PerNodeConfig []RuledConfigs `json:"perNodeConfig,omitempty"`
}

// Below struct should be same as:
// https://github.com/openshift/velero/blob/584cf1148a746838ee67aa27e3e4e0ded1f5c069/pkg/nodeagent/node_agent.go#L60-L63

// LoadAffinity is the config for data path load affinity.
// Used by the Node-Agent, that needs to match the DataMover and the RepositoryMaintenance pods.
type LoadAffinity struct {
// NodeSelector specifies the label selector to match nodes
// +optional
NodeSelector metav1.LabelSelector `json:"nodeSelector,omitempty"`
}

// Below struct should be same as:
// https://github.com/openshift/velero/blob/584cf1148a746838ee67aa27e3e4e0ded1f5c069/pkg/nodeagent/node_agent.go#L65-L71

// RuledConfigs is the config for data path load concurrency per node.
type RuledConfigs struct {
// NodeSelector specifies the label selector to match nodes
NodeSelector metav1.LabelSelector `json:"nodeSelector"`
Expand All @@ -387,35 +409,33 @@ type RuledConfigs struct {
Number int `json:"number"`
}

// LoadConcurrency is the config for data path load concurrency per node.
type LoadConcurrency struct {
// GlobalConfig specifies the concurrency number to all nodes for which per-node config is not specified
GlobalConfig int `json:"globalConfig,omitempty"`

// PerNodeConfig specifies the concurrency number to nodes matched by rules
PerNodeConfig []RuledConfigs `json:"perNodeConfig,omitempty"`
}
// Below struct should be same as:
// https://github.com/openshift/velero/blob/584cf1148a746838ee67aa27e3e4e0ded1f5c069/pkg/nodeagent/node_agent.go#L90-L105

// NodeAgentConfigMapSettings is the config for node-agent
type NodeAgentConfigMapSettings struct {
// LoadConcurrency is the config for data path load concurrency per node.
// +optional
LoadConcurrency *LoadConcurrency `json:"loadConcurrency,omitempty"`
// LoadAffinity is the config for data path load affinity.
// +optional
LoadAffinityConfig []*LoadAffinity `json:"loadAffinity,omitempty"`
// BackupPVCConfig is the config for backupPVC (intermediate PVC) of snapshot data movement
// +optional
BackupPVCConfig map[string]nodeagent.BackupPVC `json:"backupPVC,omitempty"`
// RestoreVCConfig is the config for restorePVC (intermediate PVC) of generic restore
// +optional
RestorePVCConfig *RestorePVC `json:"restorePVC,omitempty"`
RestorePVCConfig *nodeagent.RestorePVC `json:"restorePVC,omitempty"`
// PodResources is the resource config for various types of pods launched by node-agent, i.e., data mover pods.
// +optional
PodResources *kube.PodResources `json:"podResources,omitempty"`
// LoadAffinity is not required within NodeAgentConfigMapSettings,
// because we have it already from the NodeAgentConfig.PodConfig.NodeSelector
}

// Velero nodeAgentServerConfig struct used in below struct:
// https://github.com/openshift/velero/blob/8c8a6cccd78b78bd797e40189b0b9bee46a97f9e/pkg/cmd/cli/nodeagent/server.go#L87-L92

// NodeAgentConfig is the configuration for node server
// Holds the configuration for the Node Agent Server.
// https://github.com/openshift/velero/blob/8c8a6cccd78b78bd797e40189b0b9bee46a97f9e/pkg/cmd/cli/nodeagent/server.go#L87-L92
type NodeAgentConfig struct {
// Embedding NodeAgentCommonFields
// +optional
Expand Down Expand Up @@ -873,6 +893,23 @@ func (dpa *DataProtectionApplication) AutoCorrect() {

dpa.Spec.Configuration.Velero.DefaultPlugins = common.RemoveDuplicateValues(dpa.Spec.Configuration.Velero.DefaultPlugins)
dpa.Spec.Configuration.Velero.FeatureFlags = common.RemoveDuplicateValues(dpa.Spec.Configuration.Velero.FeatureFlags)

// Auto correct nodeAffinity for the node agent, but only if the new schema is not used
// The new schema will be used instead of the dpa.Spec.Configuration.NodeAgent.PodConfig
// There is need to translate map of labels to a LabelSelector with MatchLabels
if dpa.Spec.Configuration.NodeAgent != nil && dpa.Spec.Configuration.NodeAgent.PodConfig != nil && dpa.Spec.Configuration.NodeAgent.PodConfig.NodeSelector != nil {
// Only modify if LoadAffinityConfig is not already set
if dpa.Spec.Configuration.NodeAgent.LoadAffinityConfig == nil {
// Convert the NodeSelector map to a LabelSelector with MatchLabels
dpa.Spec.Configuration.NodeAgent.LoadAffinityConfig = []*LoadAffinity{
{
NodeSelector: metav1.LabelSelector{
MatchLabels: dpa.Spec.Configuration.NodeAgent.PodConfig.NodeSelector,
},
},
}
}
}
}

func hasCSIPlugin(plugins []DefaultPlugin) bool {
Expand Down
44 changes: 28 additions & 16 deletions api/v1alpha1/zz_generated.deepcopy.go

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

54 changes: 54 additions & 0 deletions bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,59 @@ spec:
- fastGC
- eagerGC
type: string
loadAffinity:
description: LoadAffinity is the config for data path load affinity.
items:
description: |-
LoadAffinity is the config for data path load affinity.
Used by the Node-Agent, that needs to match the DataMover and the RepositoryMaintenance pods.
properties:
nodeSelector:
description: NodeSelector specifies the label selector to match nodes
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
type: array
loadConcurrency:
description: LoadConcurrency is the config for data path load concurrency per node.
properties:
Expand All @@ -254,6 +307,7 @@ spec:
perNodeConfig:
description: PerNodeConfig specifies the concurrency number to nodes matched by rules
items:
description: RuledConfigs is the config for data path load concurrency per node.
properties:
nodeSelector:
description: NodeSelector specifies the label selector to match nodes
Expand Down
54 changes: 54 additions & 0 deletions config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,59 @@ spec:
- fastGC
- eagerGC
type: string
loadAffinity:
description: LoadAffinity is the config for data path load affinity.
items:
description: |-
LoadAffinity is the config for data path load affinity.
Used by the Node-Agent, that needs to match the DataMover and the RepositoryMaintenance pods.
properties:
nodeSelector:
description: NodeSelector specifies the label selector to match nodes
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: |-
A label selector requirement is a selector that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: |-
values is an array of string values. If the operator is In or NotIn,
the values array must be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
description: |-
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is "key", the
operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
type: array
loadConcurrency:
description: LoadConcurrency is the config for data path load concurrency per node.
properties:
Expand All @@ -254,6 +307,7 @@ spec:
perNodeConfig:
description: PerNodeConfig specifies the concurrency number to nodes matched by rules
items:
description: RuledConfigs is the config for data path load concurrency per node.
properties:
nodeSelector:
description: NodeSelector specifies the label selector to match nodes
Expand Down
Loading