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

OADP-4076: Add qps and burst to DPA #1395

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
6 changes: 6 additions & 0 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ type VeleroConfig struct {
// Default is 10m
// +optional
ResourceTimeout string `json:"resourceTimeout,omitempty"`
// maximum number of requests by the server to the Kubernetes API in a short period of time. (default 100)
// +optional
ClientBurst *int `json:"client-burst,omitempty"`
// maximum number of requests per second by the server to the Kubernetes API once the burst limit has been reached. (default 100)
// +optional
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"`
Expand Down
10 changes: 10 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.

Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ spec:
description: comma-separated list of pattern=N settings for file-filtered logging
type: string
type: object
client-burst:
description: maximum number of requests by the server to the Kubernetes API in a short period of time. (default 100)
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. (default 100)
type: integer
customPlugins:
description: customPlugins defines the custom plugin to be installed with Velero
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,12 @@ spec:
description: comma-separated list of pattern=N settings for file-filtered logging
type: string
type: object
client-burst:
description: maximum number of requests by the server to the Kubernetes API in a short period of time. (default 100)
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. (default 100)
type: integer
customPlugins:
description: customPlugins defines the custom plugin to be installed with Velero
items:
Expand Down
7 changes: 7 additions & 0 deletions controllers/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ func (r *DPAReconciler) customizeVeleroContainer(dpa *oadpv1alpha1.DataProtectio
veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--fs-backup-timeout=%s", getFsBackupTimeout(dpa)))
// Overriding velero restore resource priorities to OpenShift default (ie. SecurityContextConstraints needs to be restored before pod/SA)
veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--restore-resource-priorities=%s", common.DefaultRestoreResourcePriorities.String()))

if dpa.Spec.Configuration.Velero != nil && dpa.Spec.Configuration.Velero.ClientBurst != nil {
veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--client-burst=%v", *dpa.Spec.Configuration.Velero.ClientBurst))
}
if dpa.Spec.Configuration.Velero != nil && dpa.Spec.Configuration.Velero.ClientQPS != nil {
veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--client-qps=%v", *dpa.Spec.Configuration.Velero.ClientQPS))
}
setContainerDefaults(veleroContainer)
// if server args is set, override the default server args
if dpa.Spec.Configuration.Velero.Args != nil {
Expand Down
154 changes: 154 additions & 0 deletions controllers/velero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,160 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) {
},
},
},
{
name: "Override burst and qps",
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "test-Velero-CR",
Namespace: "test-ns",
},
Spec: oadpv1alpha1.DataProtectionApplicationSpec{
Configuration: &oadpv1alpha1.ApplicationConfig{
Velero: &oadpv1alpha1.VeleroConfig{
ClientBurst: ptr.To(123),
ClientQPS: ptr.To(123),
},
NodeAgent: &oadpv1alpha1.NodeAgentConfig{
UploaderType: "kopia",
},
},
},
},
veleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "test-velero-deployment",
Namespace: "test-ns",
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: veleroDeploymentMatchLabels},
},
},
wantVeleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "test-velero-deployment",
Namespace: "test-ns",
Labels: veleroDeploymentLabel,
},
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: appsv1.SchemeGroupVersion.String(),
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: veleroDeploymentMatchLabels},
Replicas: ptr.To(int32(1)),
Template: corev1.PodTemplateSpec{
ObjectMeta: veleroPodObjectMeta,
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyAlways,
ServiceAccountName: common.Velero,
Containers: []corev1.Container{
{
Name: common.Velero,
Image: common.VeleroImage,
ImagePullPolicy: corev1.PullAlways,
Ports: []corev1.ContainerPort{{Name: "metrics", ContainerPort: 8085}},
Resources: corev1.ResourceRequirements{Requests: corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("500m"), corev1.ResourceMemory: resource.MustParse("128Mi")}},
Command: []string{"/velero"},
Args: []string{
"server",
"--uploader-type=kopia",
defaultFileSystemBackupTimeout,
defaultRestoreResourcePriorities,
"--client-burst=123",
"--client-qps=123",
defaultDisableInformerCache,
},
VolumeMounts: baseVolumeMounts,
Env: baseEnvVars,
},
},
Volumes: baseVolumes,
InitContainers: []corev1.Container{},
},
},
},
},
},
{
name: "Conflicting burst and qps",
mateusoliveira43 marked this conversation as resolved.
Show resolved Hide resolved
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "test-Velero-CR",
Namespace: "test-ns",
},
Spec: oadpv1alpha1.DataProtectionApplicationSpec{
Configuration: &oadpv1alpha1.ApplicationConfig{
Velero: &oadpv1alpha1.VeleroConfig{
ClientBurst: ptr.To(123),
ClientQPS: ptr.To(123),
Args: &server.Args{
ServerConfig: server.ServerConfig{
ClientBurst: ptr.To(321),
ClientQPS: ptr.To("321"),
},
},
},
NodeAgent: &oadpv1alpha1.NodeAgentConfig{
UploaderType: "kopia",
},
},
},
},
veleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "test-velero-deployment",
Namespace: "test-ns",
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: veleroDeploymentMatchLabels},
},
},
wantVeleroDeployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "test-velero-deployment",
Namespace: "test-ns",
Labels: veleroDeploymentLabel,
},
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: appsv1.SchemeGroupVersion.String(),
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: veleroDeploymentMatchLabels},
Replicas: ptr.To(int32(1)),
Template: corev1.PodTemplateSpec{
ObjectMeta: veleroPodObjectMeta,
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyAlways,
ServiceAccountName: common.Velero,
Containers: []corev1.Container{
{
Name: common.Velero,
Image: common.VeleroImage,
ImagePullPolicy: corev1.PullAlways,
Ports: []corev1.ContainerPort{{Name: "metrics", ContainerPort: 8085}},
Resources: corev1.ResourceRequirements{Requests: corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("500m"), corev1.ResourceMemory: resource.MustParse("128Mi")}},
Command: []string{"/velero"},
Args: []string{
"server",
// should be present... "--uploader-type=kopia",
"--client-burst=321",
"--client-qps=321",
"--fs-backup-timeout=4h0m0s",
defaultRestoreResourcePriorities,
defaultDisableInformerCache,
},
VolumeMounts: baseVolumeMounts,
Env: baseEnvVars,
},
},
Volumes: baseVolumes,
InitContainers: []corev1.Container{},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down