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

Add WALG_UPLOAD_DISK_CONCURRENCY env #504

Merged
merged 6 commits into from
Oct 18, 2023
Merged
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
47 changes: 34 additions & 13 deletions controllers/postgres_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
coreosv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
networkingv1 "k8s.io/api/networking/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -441,6 +442,20 @@ func (r *PostgresReconciler) updatePodEnvironmentConfigMap(ctx context.Context,
// region
region := backupConfig.S3Region

// set the WALG_UPLOAD_DISK_CONCURRENCY based on the configured cpu limits
q, err := resource.ParseQuantity(p.Spec.Size.CPU)
if err != nil {
return fmt.Errorf("error while parsing the postgres cpu size: %w", err)
}
uploadDiskConcurrency := "1"
if q.Value() > 32 {
uploadDiskConcurrency = "32"
} else if q.Value() > 1 {
uploadDiskConcurrency = fmt.Sprint(q.Value())
}
uploadConcurrency := "32"
downloadConcurrency := "32"

// use the rest as provided in the secret
bucketName := backupConfig.S3BucketName
backupSchedule := backupConfig.Schedule
Expand All @@ -452,19 +467,25 @@ func (r *PostgresReconciler) updatePodEnvironmentConfigMap(ctx context.Context,

// create updated content for pod environment configmap
data := map[string]string{
"USE_WALG_BACKUP": "true",
"USE_WALG_RESTORE": "true",
"WALE_S3_PREFIX": "s3://" + bucketName + "/$(SCOPE)",
"WALG_S3_PREFIX": "s3://" + bucketName + "/$(SCOPE)",
"CLONE_WALG_S3_PREFIX": "s3://" + bucketName + "/$(CLONE_SCOPE)",
"WALE_BACKUP_THRESHOLD_PERCENTAGE": "100",
"AWS_ENDPOINT": awsEndpoint,
"WALE_S3_ENDPOINT": walES3Endpoint, // same as above, but slightly modified
"AWS_S3_FORCE_PATH_STYLE": "true",
"AWS_REGION": region, // now we can use AWS S3
"WALG_DISABLE_S3_SSE": walgDisableSSE, // server side encryption
"BACKUP_SCHEDULE": backupSchedule,
"BACKUP_NUM_TO_RETAIN": backupNumToRetain,
"USE_WALG_BACKUP": "true",
"USE_WALG_RESTORE": "true",
"WALE_S3_PREFIX": "s3://" + bucketName + "/$(SCOPE)",
"WALG_S3_PREFIX": "s3://" + bucketName + "/$(SCOPE)",
"CLONE_WALG_S3_PREFIX": "s3://" + bucketName + "/$(CLONE_SCOPE)",
"WALE_BACKUP_THRESHOLD_PERCENTAGE": "100",
"AWS_ENDPOINT": awsEndpoint,
"WALE_S3_ENDPOINT": walES3Endpoint, // same as above, but slightly modified
"AWS_S3_FORCE_PATH_STYLE": "true",
"AWS_REGION": region, // now we can use AWS S3
"WALG_DISABLE_S3_SSE": walgDisableSSE, // server side encryption
"BACKUP_SCHEDULE": backupSchedule,
"BACKUP_NUM_TO_RETAIN": backupNumToRetain,
"WALG_UPLOAD_DISK_CONCURRENCY": uploadDiskConcurrency,
"CLONE_WALG_UPLOAD_DISK_CONCURRENCY": uploadDiskConcurrency,
"WALG_UPLOAD_CONCURRENCY": uploadConcurrency,
"CLONE_WALG_UPLOAD_CONCURRENCY": uploadConcurrency,
"WALG_DOWNLOAD_CONCURRENCY": downloadConcurrency,
"CLONE_WALG_DOWNLOAD_CONCURRENCY": downloadConcurrency,
}

cm := &corev1.ConfigMap{}
Expand Down
Loading