Skip to content

Commit 55cb41f

Browse files
pstibranypracucci
andauthored
Blocks copy tool (#169)
* Blocks copy tool Signed-off-by: Peter Štibraný <[email protected]> * Make lint happy. Signed-off-by: Peter Štibraný <[email protected]> * Check if block was copied first. Signed-off-by: Peter Štibraný <[email protected]> * Add basic metrics and http server for scraping them. Signed-off-by: Peter Štibraný <[email protected]> * Dockerfile and Makefile updates. Signed-off-by: Peter Štibraný <[email protected]> * Update cmd/blockscopy/main.go Co-authored-by: Marco Pracucci <[email protected]> Co-authored-by: Marco Pracucci <[email protected]>
1 parent a0495b8 commit 55cb41f

File tree

4 files changed

+507
-0
lines changed

4 files changed

+507
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cortextool: cmd/cortextool/cortextool
1414
chunktool: cmd/chunktool/chunktool
1515
logtool: cmd/logtool/logtool
1616
e2ealerting: cmd/e2ealerting/e2ealerting
17+
blockscopy: cmd/blockscopy/blockscopy
1718

1819
benchtool-image:
1920
$(SUDO) docker build -t $(IMAGE_PREFIX)/benchtool -f cmd/benchtool/Dockerfile .
@@ -37,6 +38,10 @@ e2ealerting-image:
3738
push-e2ealerting-image: e2ealerting-image
3839
$(SUDO) docker push $(IMAGE_PREFIX)/e2ealerting:$(IMAGE_TAG)
3940

41+
blockscopy-image:
42+
$(SUDO) docker build -t $(IMAGE_PREFIX)/blockscopy -f cmd/blockscopy/Dockerfile .
43+
$(SUDO) docker tag $(IMAGE_PREFIX)/blockscopy $(IMAGE_PREFIX)/blockscopy:$(IMAGE_TAG)
44+
4045
cmd/benchtool/benchtool: $(APP_GO_FILES) cmd/benchtool/main.go
4146
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
4247

@@ -55,6 +60,9 @@ cmd/e2ealerting/e2ealerting: $(APP_GO_FILES) cmd/e2ealerting/main.go
5560
cmd/rules-migrator/rules-migrator: $(APP_GO_FILES) cmd/rules-migrator/main.go
5661
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
5762

63+
cmd/blockscopy/blockscopy: $(APP_GO_FILES) cmd/blockscopy/main.go
64+
CGO_ENABLED=0 go build $(GO_FLAGS) -o $@ ./$(@D)
65+
5866
lint:
5967
golangci-lint run -v
6068

@@ -73,3 +81,4 @@ clean:
7381
rm -rf cmd/chunktool/chunktool
7482
rm -rf cmd/logtool/logtool
7583
rm -rf cmd/e2ealerting/e2ealerting
84+
rm -rf cmd/blockscopy/blockscopy

cmd/blockscopy/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.16.3-stretch as build
2+
ARG GOARCH="amd64"
3+
COPY . /build_dir
4+
WORKDIR /build_dir
5+
ENV GOPROXY=https://proxy.golang.org
6+
RUN make clean && make chunktool
7+
8+
FROM alpine:3.13
9+
RUN apk add --update --no-cache ca-certificates
10+
COPY --from=build /build_dir/cmd/blockscopy/blockscopy /usr/bin/blockscopy
11+
EXPOSE 80
12+
ENTRYPOINT [ "/usr/bin/blockscopy" ]

cmd/blockscopy/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Blocks copy
2+
3+
This program can copy Cortex blocks between two GCS buckets. It is GCS specific and uses special calls to copy
4+
files between buckets directly, without download to a local system first.
5+
6+
Blocks copy can run in one-time mode, or as a service and do regular copies.
7+
8+
It can be configured with minimum block time range to avoid copying of blocks that are too small.
9+
It can also be configured with list of users to copy, or avoid copying blocks for.

0 commit comments

Comments
 (0)