Skip to content

Commit

Permalink
Merge pull request #597 from zhl003/graceful_failover
Browse files Browse the repository at this point in the history
*: Prevent Leader from accidentally hanging up data inconsistency
  • Loading branch information
acekingke authored Jul 14, 2022
2 parents 0c496e3 + 645e893 commit 6076749
Show file tree
Hide file tree
Showing 14 changed files with 705 additions and 28 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
# RUN go env -w GOPROXY=https://goproxy.cn,direct; \
# go mod download
# RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download

# Copy the go source
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.sidecar
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY go.sum go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
# RUN go env -w GOPROXY=https://goproxy.cn,direct; \
# RUN go env -w GOPROXY=https://goproxy.cn,direct;
# go mod download
RUN go mod download

Expand Down
25 changes: 25 additions & 0 deletions build/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.16 as builder

WORKDIR /
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go env -w GOPROXY=https://goproxy.cn,direct;
# go mod download
RUN go mod download

# Copy the go source
COPY cmd/healthcheck/main.go cmd/healthcheck/main.go
COPY utils/ utils/
COPY internal/ internal/
# COPY api/ api/
# COPY mysqlcluster/ mysqlcluster/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/healthcheck cmd/healthcheck/main.go

FROM percona/percona-server:5.7.34

COPY --from=builder /bin/healthcheck /healthcheck
54 changes: 40 additions & 14 deletions build/xenon/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
FROM golang:1.16 as builder
##############################################################################
# Build Xenon
###############################################################################

WORKDIR /
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go env -w GOPROXY=https://goproxy.cn,direct;
#     go mod download
RUN  go mod download
FROM golang:1.16 as builder

ARG XENON_BRANCH=origin_test
RUN go env -w GOPROXY=https://goproxy.cn,direct && go env -w GO111MODULE=off;
RUN set -ex; \
mkdir -p /go/src/github.com/radondb; \
cd /go/src/github.com/radondb; \
git clone --branch $XENON_BRANCH https://github.com/zhl003/xenon.git; \
cd xenon; \
make build
WORKDIR /workspace
# Copy the go source
COPY cmd/xenon/main.go cmd/xenon/main.go
COPY utils/ utils/

COPY go.mod go.mod
COPY go.sum go.sum
RUN go env -w GO111MODULE=on && go mod download
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/xenonchecker cmd/xenon/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o xenonchecker cmd/xenon/main.go
###############################################################################
# Docker image for Xenon
###############################################################################

FROM alpine:3.13

FROM radondb/xenon:1.1.5-alpha
RUN set -ex \
&& addgroup -g 1001 mysql && adduser -u 1001 -g 1001 -S mysql \
&& apk add --no-cache curl bash jq \
&& mkdir -p /etc/xenon /var/lib/xenon /lib64 \
&& ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 \
&& echo "/etc/xenon/xenon.json" > /config.path \
# allow to change config files
&& chown -R 1001:1001 /etc/xenon /var/lib/xenon

COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenon /usr/local/bin/xenon
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenoncli /usr/local/bin/xenoncli
COPY --from=builder /workspace/xenonchecker /xenonchecker
USER 1001
WORKDIR /
EXPOSE 8801
VOLUME ["/var/lib/xenon", "/etc/xenon"]

COPY --from=builder /bin/xenonchecker /xenonchecker
ENTRYPOINT ["xenon"]
CMD ["-c", "/etc/xenon/xenon.json"]
Loading

0 comments on commit 6076749

Please sign in to comment.