Skip to content

Commit f5004ee

Browse files
committed
fix applying macros to s3 endpoint in object disk during restore embedded backups, fix #750
1 parent d15459c commit f5004ee

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ IMPROVEMENTS
55
BUG FIXES
66
- fix restore for object disk frozen_metadata.txt fix [752](https://github.com/Altinity/clickhouse-backup/issues/752)
77
- fix more corner cases for `check_parts_columns: true`, fix [747](https://github.com/Altinity/clickhouse-backup/issues/747)
8-
8+
- fix applying macros to s3 endpoint in object disk during restore embedded backups, fix [750](https://github.com/Altinity/clickhouse-backup/issues/750)
9+
910
# v2.4.1
1011
IMPROVEMENTS
1112
- switch to go-1.21

pkg/storage/object_disk/object_disk.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,18 @@ func getObjectDisksCredentials(ctx context.Context, ch *clickhouse.ClickHouse) (
320320
}
321321
if endPointNode := d.SelectElement("endpoint"); endPointNode != nil {
322322
creds.EndPoint = strings.Trim(endPointNode.InnerText(), "\r\n \t")
323+
if creds.EndPoint, err = ch.ApplyMacros(ctx, creds.EndPoint); err != nil {
324+
return nil, fmt.Errorf("%s -> /%s/storage_configuration/disks/%s apply macros to <endpoint> error: %v", configFile, root.Data, diskName, err)
325+
}
323326
} else {
324327
return nil, fmt.Errorf("%s -> /%s/storage_configuration/disks/%s doesn't contains <endpoint>", configFile, root.Data, diskName)
325328
}
326329
if regionNode := d.SelectElement("region"); regionNode != nil {
327330
creds.S3Region = strings.Trim(regionNode.InnerText(), "\r\n \t")
328331
}
332+
creds.S3StorageClass = "STANDARD"
329333
if storageClassNode := d.SelectElement("s3_storage_class"); storageClassNode != nil {
330334
creds.S3StorageClass = strings.Trim(storageClassNode.InnerText(), "\r\n \t")
331-
} else {
332-
creds.S3StorageClass = "STANDARD"
333335
}
334336
accessKeyNode := d.SelectElement("access_key_id")
335337
secretKeyNode := d.SelectElement("secret_access_key")

test/integration/config-s3-embedded.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ s3:
2929
acl: private
3030
force_path_style: true
3131
path: backup/{cluster}/{shard}
32+
object_disk_path: object_disk/{cluster}/{shard}
3233
disable_ssl: true
3334
compression_format: none
3435
api:

test/integration/dynamic_settings.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ cat <<EOT > /etc/clickhouse-server/config.d/storage_configuration_s3.xml
8989
<disks>
9090
<disk_s3>
9191
<type>s3</type>
92-
<endpoint>http://minio:9000/clickhouse/disk_s3/</endpoint>
92+
<endpoint>http://minio:9000/clickhouse/disk_s3/{cluster}/{shard}/</endpoint>
9393
<!-- https://github.com/Altinity/clickhouse-backup/issues/691
9494
<access_key_id>access-key</access_key_id>
9595
<secret_access_key>it-is-my-super-secret-key</secret_access_key>
@@ -124,7 +124,7 @@ cat <<EOT > /etc/clickhouse-server/config.d/storage_configuration_gcs.xml
124124
<disks>
125125
<disk_gcs_over_s3>
126126
<type>s3</type>
127-
<endpoint>https://storage.googleapis.com/${QA_GCS_OVER_S3_BUCKET}/clickhouse_backup_disk_gcs_over_s3/${HOSTNAME}/</endpoint>
127+
<endpoint>https://storage.googleapis.com/${QA_GCS_OVER_S3_BUCKET}/clickhouse_backup_disk_gcs_over_s3/${HOSTNAME}/{cluster}/{shard}/</endpoint>
128128
<access_key_id>${QA_GCS_OVER_S3_ACCESS_KEY}</access_key_id>
129129
<secret_access_key>${QA_GCS_OVER_S3_SECRET_KEY}</secret_access_key>
130130
<!-- to avoid slow startup -->
@@ -206,7 +206,7 @@ cat <<EOT > /etc/clickhouse-server/config.d/backup_storage_configuration_s3.xml
206206
<disks>
207207
<backups_s3>
208208
<type>s3</type>
209-
<endpoint>http://minio:9000/clickhouse/backups_s3/</endpoint>
209+
<endpoint>http://minio:9000/clickhouse/backups_s3/{cluster}/{shard}/</endpoint>
210210
<!-- https://github.com/Altinity/clickhouse-backup/issues/691
211211
<access_key_id>access-key</access_key_id>
212212
<secret_access_key>it-is-my-super-secret-key</secret_access_key>
@@ -243,7 +243,7 @@ cat <<EOT > /etc/clickhouse-server/config.d/backup_storage_configuration_s3_plai
243243
<disks>
244244
<backups_s3_plain>
245245
<type>s3_plain</type>
246-
<endpoint>http://minio:9000/clickhouse/backups_s3_plain/</endpoint>
246+
<endpoint>http://minio:9000/clickhouse/backups_s3_plain/{cluster}/{shard}/</endpoint>
247247
<!-- https://github.com/Altinity/clickhouse-backup/issues/691
248248
<access_key_id>access-key</access_key_id>
249249
<secret_access_key>it-is-my-super-secret-key</secret_access_key>

0 commit comments

Comments
 (0)