Skip to content

Commit 94f9db2

Browse files
committed
feat: Support VM HA
1 parent 6bdf25a commit 94f9db2

60 files changed

Lines changed: 3520 additions & 46 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
with:
1515
go-version: 1.19.3
1616

17+
- run: sudo apt-get update && sudo apt-get install libaio-dev libsanlock-dev
18+
1719
- run: make test
1820

1921
- uses: codecov/codecov-action@v2

.github/workflows/release.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@ jobs:
2323
username: smartxrocks
2424
password: ${{ secrets.DOCKERHUB_PUSH_TOKEN }}
2525

26+
- id: build_lockspace_initializer
27+
uses: docker/build-push-action@v2
28+
with:
29+
file: build/lockspace-initializer/Dockerfile
30+
tags: smartxworks/lockspace-initializer:${{ steps.get_version.outputs.version }}
31+
platforms: linux/amd64,linux/arm64
32+
push: true
33+
34+
- id: build_lockspace_attacher
35+
uses: docker/build-push-action@v2
36+
with:
37+
file: build/lockspace-attacher/Dockerfile
38+
tags: smartxworks/lockspace-attacher:${{ steps.get_version.outputs.version }}
39+
platforms: linux/amd64,linux/arm64
40+
push: true
41+
42+
- id: build_lockspace_detector
43+
uses: docker/build-push-action@v2
44+
with:
45+
file: build/lockspace-detector/Dockerfile
46+
tags: smartxworks/lockspace-detector:${{ steps.get_version.outputs.version }}
47+
platforms: linux/amd64,linux/arm64
48+
push: true
49+
2650
- id: build_virt_prerunner
2751
uses: docker/build-push-action@v2
2852
with:
@@ -34,7 +58,11 @@ jobs:
3458
- uses: docker/build-push-action@v2
3559
with:
3660
file: build/virt-controller/Dockerfile
37-
build-args: PRERUNNER_IMAGE=smartxworks/virt-prerunner:${{ steps.get_version.outputs.version }}@${{ steps.build_virt_prerunner.outputs.digest }}
61+
build-args: |
62+
PRERUNNER_IMAGE=smartxworks/virt-prerunner:${{ steps.get_version.outputs.version }}@${{ steps.build_virt_prerunner.outputs.digest }}
63+
INITIALIZER_IMAGE=smartxworks/lockspace-initializer:${{ steps.get_version.outputs.version }}@${{ steps.build_lockspace_initializer.outputs.digest }}
64+
ATTACHER_IMAGE=smartxworks/lockspace-attacher:${{ steps.get_version.outputs.version }}@${{ steps.build_lockspace_attacher.outputs.digest }}
65+
DETECTOR_IMAGE=smartxworks/lockspace-detector:${{ steps.get_version.outputs.version }}@${{ steps.build_lockspace_detector.outputs.digest }}
3866
tags: smartxworks/virt-controller:${{ steps.get_version.outputs.version }}
3967
platforms: linux/amd64,linux/arm64
4068
push: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.19-alpine AS builder
2+
3+
RUN apk add --no-cache gcc musl-dev libaio-dev
4+
RUN apk add --no-cache sanlock-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
5+
6+
WORKDIR /workspace
7+
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
RUN go mod download
11+
12+
COPY cmd/ cmd/
13+
COPY pkg/ pkg/
14+
RUN --mount=type=cache,target=/root/.cache/go-build go build -a cmd/lockspace-attacher/main.go
15+
16+
FROM alpine
17+
18+
RUN apk add --no-cache sanlock --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
19+
20+
COPY --from=builder /workspace/main /usr/bin/lockspace-attacher
21+
ENTRYPOINT ["lockspace-attacher"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.19-alpine AS builder
2+
3+
RUN apk add --no-cache gcc musl-dev libaio-dev
4+
RUN apk add --no-cache sanlock-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
5+
6+
WORKDIR /workspace
7+
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
RUN go mod download
11+
12+
COPY cmd/ cmd/
13+
COPY pkg/ pkg/
14+
RUN --mount=type=cache,target=/root/.cache/go-build go build -a cmd/lockspace-detector/main.go
15+
16+
FROM alpine
17+
18+
RUN apk add --no-cache sanlock --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
19+
20+
COPY --from=builder /workspace/main /usr/bin/lockspace-detector
21+
ENTRYPOINT ["lockspace-detector"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.19-alpine AS builder
2+
3+
RUN apk add --no-cache gcc musl-dev libaio-dev
4+
RUN apk add --no-cache sanlock-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
5+
6+
WORKDIR /workspace
7+
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
RUN go mod download
11+
12+
COPY cmd/ cmd/
13+
COPY pkg/ pkg/
14+
RUN --mount=type=cache,target=/root/.cache/go-build go build -a cmd/lockspace-initializer/main.go
15+
16+
FROM alpine
17+
18+
RUN apk add --no-cache sanlock --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
19+
20+
COPY --from=builder /workspace/main /usr/bin/lockspace-initializer
21+
ENTRYPOINT ["lockspace-initializer"]

build/virt-controller/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ FROM alpine
1414

1515
ARG PRERUNNER_IMAGE
1616
ENV PRERUNNER_IMAGE=$PRERUNNER_IMAGE
17+
ARG DETECTOR_IMAGE
18+
ENV DETECTOR_IMAGE=$DETECTOR_IMAGE
19+
ARG ATTACHER_IMAGE
20+
ENV ATTACHER_IMAGE=$ATTACHER_IMAGE
21+
ARG INITIALIZER_IMAGE
22+
ENV INITIALIZER_IMAGE=$INITIALIZER_IMAGE
1723

1824
COPY --from=builder /workspace/main /usr/bin/virt-controller
1925
ENTRYPOINT ["virt-controller"]

build/virt-prerunner/Dockerfile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM golang:1.19-alpine AS builder
22

3-
RUN apk add --no-cache gcc musl-dev
3+
RUN apk add --no-cache gcc musl-dev libaio-dev
4+
RUN apk add --no-cache sanlock-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
45

56
WORKDIR /workspace
67

@@ -14,7 +15,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build go build -a cmd/virt-prerunn
1415

1516
FROM alpine
1617

17-
RUN apk add --no-cache curl screen dnsmasq cdrkit iptables iproute2 qemu-virtiofsd dpkg util-linux s6-overlay nmap-ncat
18+
RUN apk add --no-cache curl screen dnsmasq cdrkit iptables iproute2 qemu-virtiofsd dpkg util-linux tini nmap-ncat
19+
RUN apk add --no-cache sanlock --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
1820

1921
RUN set -eux; \
2022
mkdir /var/lib/cloud-hypervisor; \
@@ -34,19 +36,9 @@ RUN set -eux; \
3436
chmod +x /usr/bin/cloud-hypervisor; \
3537
chmod +x /usr/bin/ch-remote
3638

37-
COPY build/virt-prerunner/cloud-hypervisor-type /etc/s6-overlay/s6-rc.d/cloud-hypervisor/type
38-
COPY build/virt-prerunner/cloud-hypervisor-run.sh /etc/s6-overlay/s6-rc.d/cloud-hypervisor/run
39-
COPY build/virt-prerunner/cloud-hypervisor-finish.sh /etc/s6-overlay/s6-rc.d/cloud-hypervisor/finish
40-
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/cloud-hypervisor
41-
4239
COPY --from=builder /workspace/main /usr/bin/virt-prerunner
43-
COPY build/virt-prerunner/virt-prerunner-type /etc/s6-overlay/s6-rc.d/virt-prerunner/type
44-
COPY build/virt-prerunner/virt-prerunner-up /etc/s6-overlay/s6-rc.d/virt-prerunner/up
45-
COPY build/virt-prerunner/virt-prerunner-run.sh /etc/s6-overlay/scripts/virt-prerunner-run.sh
46-
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/virt-prerunner
47-
ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2
4840

49-
ENTRYPOINT ["/init"]
41+
ENTRYPOINT ["tini", "-s", "-g", "--", "/usr/bin/virt-prerunner"]
5042

5143
COPY build/virt-prerunner/iptables-wrapper /sbin/iptables-wrapper
5244
RUN update-alternatives --install /sbin/iptables iptables /sbin/iptables-wrapper 100

build/virt-prerunner/cloud-hypervisor-finish.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

build/virt-prerunner/cloud-hypervisor-run.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

build/virt-prerunner/cloud-hypervisor-type

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)