From f5004ee88e3471680722cb7d856b558bf59dee8e Mon Sep 17 00:00:00 2001 From: Slach Date: Sat, 7 Oct 2023 11:15:01 +0400 Subject: [PATCH] fix applying macros to s3 endpoint in object disk during restore embedded backups, fix https://github.com/Altinity/clickhouse-backup/issues/750 --- ChangeLog.md | 3 ++- pkg/storage/object_disk/object_disk.go | 6 ++++-- test/integration/config-s3-embedded.yml | 1 + test/integration/dynamic_settings.sh | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index a9588cce..721cb102 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,7 +5,8 @@ IMPROVEMENTS BUG FIXES - fix restore for object disk frozen_metadata.txt fix [752](https://github.com/Altinity/clickhouse-backup/issues/752) - fix more corner cases for `check_parts_columns: true`, fix [747](https://github.com/Altinity/clickhouse-backup/issues/747) - +- fix applying macros to s3 endpoint in object disk during restore embedded backups, fix [750](https://github.com/Altinity/clickhouse-backup/issues/750) + # v2.4.1 IMPROVEMENTS - switch to go-1.21 diff --git a/pkg/storage/object_disk/object_disk.go b/pkg/storage/object_disk/object_disk.go index 82aa669c..3bf059dd 100644 --- a/pkg/storage/object_disk/object_disk.go +++ b/pkg/storage/object_disk/object_disk.go @@ -320,16 +320,18 @@ func getObjectDisksCredentials(ctx context.Context, ch *clickhouse.ClickHouse) ( } if endPointNode := d.SelectElement("endpoint"); endPointNode != nil { creds.EndPoint = strings.Trim(endPointNode.InnerText(), "\r\n \t") + if creds.EndPoint, err = ch.ApplyMacros(ctx, creds.EndPoint); err != nil { + return nil, fmt.Errorf("%s -> /%s/storage_configuration/disks/%s apply macros to error: %v", configFile, root.Data, diskName, err) + } } else { return nil, fmt.Errorf("%s -> /%s/storage_configuration/disks/%s doesn't contains ", configFile, root.Data, diskName) } if regionNode := d.SelectElement("region"); regionNode != nil { creds.S3Region = strings.Trim(regionNode.InnerText(), "\r\n \t") } + creds.S3StorageClass = "STANDARD" if storageClassNode := d.SelectElement("s3_storage_class"); storageClassNode != nil { creds.S3StorageClass = strings.Trim(storageClassNode.InnerText(), "\r\n \t") - } else { - creds.S3StorageClass = "STANDARD" } accessKeyNode := d.SelectElement("access_key_id") secretKeyNode := d.SelectElement("secret_access_key") diff --git a/test/integration/config-s3-embedded.yml b/test/integration/config-s3-embedded.yml index d8071dcd..3ff7061f 100644 --- a/test/integration/config-s3-embedded.yml +++ b/test/integration/config-s3-embedded.yml @@ -29,6 +29,7 @@ s3: acl: private force_path_style: true path: backup/{cluster}/{shard} + object_disk_path: object_disk/{cluster}/{shard} disable_ssl: true compression_format: none api: diff --git a/test/integration/dynamic_settings.sh b/test/integration/dynamic_settings.sh index 35828c5c..57b4600c 100644 --- a/test/integration/dynamic_settings.sh +++ b/test/integration/dynamic_settings.sh @@ -89,7 +89,7 @@ cat < /etc/clickhouse-server/config.d/storage_configuration_s3.xml s3 - http://minio:9000/clickhouse/disk_s3/ + http://minio:9000/clickhouse/disk_s3/{cluster}/{shard}/ @@ -206,7 +206,7 @@ cat < /etc/clickhouse-server/config.d/backup_storage_configuration_s3.xml s3 - http://minio:9000/clickhouse/backups_s3/ + http://minio:9000/clickhouse/backups_s3/{cluster}/{shard}/