Skip to content

Commit

Permalink
OADP-4076: Add qps and burst to DPA (openshift#1395)
Browse files Browse the repository at this point in the history
* fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

* fixup! fix: Default value of qps and burst

Signed-off-by: Mateus Oliveira <[email protected]>

---------

Signed-off-by: Mateus Oliveira <[email protected]>
(cherry picked from commit 0a8b70f)
  • Loading branch information
mateusoliveira43 committed Aug 2, 2024
1 parent 1db303e commit c5057da
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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 @@ -569,6 +569,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 @@ -4558,6 +4558,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",
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

0 comments on commit c5057da

Please sign in to comment.