Skip to content

Commit

Permalink
Add the mount vineyard socket dockerfile for fluid integration (#1704)
Browse files Browse the repository at this point in the history
Add the mount vineyard socket dockerfile and we need to push it to our official docker hub when merged.

Fixes part of #1596

Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji authored Dec 29, 2023
1 parent 818ad3b commit ad0f5be
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
REGISTRY := ghcr.io/v6d-io/v6d
RELEASE_REGISTRY := docker.io/vineyardcloudnative

# can be: x86_64, aarch64
PLATFORM := x86_64
Expand Down Expand Up @@ -36,6 +37,10 @@ PYTHON_DEV_REGISTRY := $(REGISTRY)
PYTHON_DEV_IMAGE := vineyard-python-dev
PYTHON_DEV_TAG := latest_$(PLATFORM)

VINEYARD_FLUID_MOUNT_REGISTRY := $(RELEASE_REGISTRY)
VINEYARD_FLUID_MOUNT_IMAGE := vineyard-fluid-mount
VINEYARD_FLUID_MOUNT_TAG := latest

BUILD_PROGRESS ?= auto

all: docker-build docker-push
Expand Down Expand Up @@ -115,3 +120,10 @@ build-python-dev:
-f ./Dockerfile.vineyard-python-dev \
-t $(PYTHON_DEV_REGISTRY)/$(PYTHON_DEV_IMAGE):$(PYTHON_DEV_TAG)
.PHONY: build-python-dev


# build vineyard-fluid-mount image
vineyard-fluid-mount:
docker build ./vineyard-fluid-mount \
-t $(VINEYARD_FLUID_MOUNT_REGISTRY)/$(VINEYARD_FLUID_MOUNT_IMAGE):$(VINEYARD_FLUID_MOUNT_TAG)
.PHONY: vineyard-fluid-mount
6 changes: 6 additions & 0 deletions docker/vineyard-fluid-mount/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM busybox:1.36.1

COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

CMD ["/entrypoint.sh"]
48 changes: 48 additions & 0 deletions docker/vineyard-fluid-mount/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
set -ex
NAMESPACE=$MOUNT_NAMESPACE
VINEYARD_NAME=$VINEYARD_FULL_NAME
MARKER=$PRESTOP_MARKER
MOUNT_DIR="/runtime-mnt/vineyard/$NAMESPACE/$VINEYARD_NAME"
SOCKET_FILE="$MOUNT_DIR/vineyard-fuse/vineyard.sock"
FUSE_DIR="$MOUNT_DIR/vineyard-fuse"
RPC_CONFIG_FILE="$MOUNT_DIR/vineyard-fuse/rpc-conf/VINEYARD_RPC_ENDPOINT"
VINEYARD_YAML_FILE="$FUSE_DIR/vineyard.yaml"

# Write the IPCSocket and RPCEndpoints to the vineyard configurations YAML file
write_yaml_config() {
echo "Vineyard:" > $VINEYARD_YAML_FILE
echo " IPCSocket: vineyard.sock" >> $VINEYARD_YAML_FILE
echo " RPCEndpoint: $1" >> $VINEYARD_YAML_FILE
}

mkdir -p $FUSE_DIR
while true; do
# check if prestop marker exists, if so, skip mounting
if [ -f $MARKER ]; then
echo "PreStop hook is in progress, skip mounting."
break
fi
# before mounting, store the rpc endpoint to a variable
if [ -f $RPC_CONFIG_FILE ]; then
VINEYARD_RPC_ENDPOINT=$(cat $RPC_CONFIG_FILE)
else
echo "rpc config file $RPC_CONFIG_FILE does not exist."
fi

if [ ! -S $SOCKET_FILE ]; then
echo "Checking if vineyard-fuse is already a mount point..."
if ! mountpoint -q $FUSE_DIR; then
echo "mount vineyard socket..."
mount --bind $MOUNT_DIR $FUSE_DIR
echo "write vineyard ipc socket and rpc endpoint to vineyard configuration YAML..."
write_yaml_config "$VINEYARD_RPC_ENDPOINT"
else
echo "$FUSE_DIR is already a mount point."
fi
else
echo "$SOCKET_FILE exists."
fi
# wait for a minute so that the fuse mount point can be checked again
sleep 60
done

0 comments on commit ad0f5be

Please sign in to comment.