Skip to content

Commit

Permalink
fix object_disk.CopyObject during restore to allow use properly S3 en…
Browse files Browse the repository at this point in the history
…dpoint, remove fips version from build-race in Makefile
  • Loading branch information
Slach committed Dec 13, 2023
1 parent d79255f commit d510c4c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.4.13
BUG FIXES
- fix object_disk.CopyObject during restore to allow use properly S3 endpoint

# v2.4.12
BUG FIXES
- fix CopyObject to use simple CopyObject call, instead of multipart for zero object size, for backup S3 disks
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define DESC =
Support of incremental backups on remote storages'
endef
GO_BUILD = go build -buildvcs=false -ldflags "-X 'main.version=$(VERSION)' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.buildDate=$(DATE)'"
GO_BUILD_STATIC = go build -buildvcs=false -ldflags "-X 'main.version=$(VERSION)-fips' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.buildDate=$(DATE)' -linkmode=external -extldflags '-static'"
GO_BUILD_STATIC = go build -buildvcs=false -ldflags "-X 'main.version=$(VERSION)' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.buildDate=$(DATE)' -linkmode=external -extldflags '-static'"
GO_BUILD_STATIC_FIPS = go build -buildvcs=false -ldflags "-X 'main.version=$(VERSION)-fips' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.buildDate=$(DATE)' -linkmode=external -extldflags '-static'"
PKG_FILES = build/$(NAME)_$(VERSION).amd64.deb build/$(NAME)_$(VERSION).arm64.deb build/$(NAME)-$(VERSION)-1.amd64.rpm build/$(NAME)-$(VERSION)-1.arm64.rpm
HOST_OS = $(shell bash -c 'source <(go env) && echo $$GOHOSTOS')
HOST_ARCH = $(shell bash -c 'source <(go env) && echo $$GOHOSTARCH')
Expand Down Expand Up @@ -55,15 +56,15 @@ build/linux/arm64/$(NAME)-fips build/darwin/arm64/$(NAME)-fips: GOARCH = arm64
build/linux/amd64/$(NAME)-fips build/linux/arm64/$(NAME)-fips: GOOS = linux
build/darwin/amd64/$(NAME)-fips build/darwin/arm64/$(NAME)-fips: GOOS = darwin
build/linux/amd64/$(NAME)-fips build/darwin/amd64/$(NAME)-fips:
CC=musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD_STATIC) -o $@ ./cmd/$(NAME) && \
CC=musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD_STATIC_FIPS) -o $@ ./cmd/$(NAME) && \
go tool nm $@ > /tmp/$(NAME)-fips-tags.txt && \
grep '_Cfunc__goboringcrypto_' /tmp/$(NAME)-fips-tags.txt 1> /dev/null && \
rm -fv /tmp/$(NAME)-fips-tags.txt

# TODO remove ugly workaround, https://www.perplexity.ai/search/2ead4c04-060a-4d78-a75f-f26835238438
build/linux/arm64/$(NAME)-fips build/darwin/arm64/$(NAME)-fips:
bash -xce 'if [[ ! -f ~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc ]]; then wget -q -P ~ https://musl.cc/aarch64-linux-musl-cross.tgz; tar -xvf ~/aarch64-linux-musl-cross.tgz -C ~; fi' && \
CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD_STATIC) -o $@ ./cmd/$(NAME) && \
CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD_STATIC_FIPS) -o $@ ./cmd/$(NAME) && \
go tool nm $@ > /tmp/$(NAME)-fips-tags.txt && \
grep '_Cfunc__goboringcrypto_' /tmp/$(NAME)-fips-tags.txt 1> /dev/null && \
rm -fv /tmp/$(NAME)-fips-tags.txt
Expand Down Expand Up @@ -128,7 +129,7 @@ $(NAME)/$(NAME)-race:
build-race-fips: $(NAME)/$(NAME)-race-fips

$(NAME)/$(NAME)-race-fips:
CC=musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 $(GO_BUILD_STATIC) -cover -gcflags "all=-N -l" -race -o $@ ./cmd/$(NAME)
CC=musl-gcc GOEXPERIMENT=boringcrypto CGO_ENABLED=1 $(GO_BUILD_STATIC_FIPS) -cover -gcflags "all=-N -l" -race -o $@ ./cmd/$(NAME)


# run `docker buildx create --use` first time
Expand Down
2 changes: 1 addition & 1 deletion pkg/backup/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ func (b *Backuper) downloadObjectDiskParts(ctx context.Context, backupName strin
return err
}
if objMeta.StorageObjectCount < 1 && objMeta.Version != object_disk.VersionRelativePath {
return fmt.Errorf("%s: invalid object_dist.Metadata: %#v", fPath, objMeta)
return fmt.Errorf("%s: invalid object_disk.Metadata: %#v", fPath, objMeta)
}
var srcBucket, srcKey string
for _, storageObject := range objMeta.StorageObjects {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/object_disk/object_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ func makeObjectDiskConnection(ctx context.Context, ch *clickhouse.ClickHouse, cf
if err != nil {
return nil, err
}
s3cfg.Endpoint = s3URL.Scheme + "://" + s3URL.Host
if cfg.S3.Concurrency > 0 {
s3cfg.Concurrency = cfg.S3.Concurrency
}
Expand Down Expand Up @@ -471,6 +470,7 @@ func makeObjectDiskConnection(ctx context.Context, ch *clickhouse.ClickHouse, cf
s3cfg.Path = strings.Trim(s3URL.Path, "/")
s3cfg.ForcePathStyle = false
} else {
s3cfg.Endpoint = s3URL.Scheme + "://" + s3URL.Host
pathItems := strings.Split(strings.Trim(s3URL.Path, "/"), "/")
s3cfg.Bucket = pathItems[0]
s3cfg.Path = path.Join(pathItems[1:]...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ func (s *S3) remotePager(ctx context.Context, s3Path string, recursive bool, pro
}

func (s *S3) CopyObject(ctx context.Context, srcBucket, srcKey, dstKey string) (int64, error) {
s.Log.Debugf("S3->CopyObject %s/%s -> %s/%s", srcBucket, srcKey, s.Config.Bucket, dstKey)
dstKey = path.Join(s.Config.ObjectDiskPath, dstKey)
s.Log.Debugf("S3->CopyObject %s/%s -> %s/%s", srcBucket, srcKey, s.Config.Bucket, dstKey)
if strings.Contains(s.Config.Endpoint, "storage.googleapis.com") {
params := &s3.CopyObjectInput{
Bucket: aws.String(s.Config.Bucket),
Expand Down

0 comments on commit d510c4c

Please sign in to comment.