Skip to content

Commit

Permalink
Create a hard link of vineyard socket rather than mount its parent di…
Browse files Browse the repository at this point in the history
…rectory. (#1763)

- Create a hard link of vineyard socket rather than mount its parent
   directory in `vineyard-fluid-fuse`.
- Change the vineyard configuration from `vineyard.yaml` to
  `config.yaml`.

Related to fluid-cloudnative/fluid#3713

Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji authored Feb 21, 2024
1 parent 07e0fb0 commit a0d38e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
26 changes: 11 additions & 15 deletions docker/vineyard-fluid-fuse/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -ex

SOCKET_FILE="$FUSE_DIR/vineyard.sock"
RPC_CONFIG_FILE="$RPC_CONF_DIR/VINEYARD_RPC_ENDPOINT"
VINEYARD_YAML_FILE="$FUSE_DIR/vineyard.yaml"
VINEYARD_YAML_FILE="$FUSE_DIR/vineyard-config.yaml"

# Write the IPCSocket and RPCEndpoints to the vineyard configurations YAML file
write_yaml_config() {
Expand All @@ -14,31 +14,27 @@ write_yaml_config() {

mkdir -p $FUSE_DIR
while true; do
# check if prestop marker exists, if so, skip mounting
# check if prestop marker exists, if so, skip creating the hard link
if [ -f $PRESTOP_MARKER ]; then
echo "PreStop hook is in progress, skip mounting."
echo "PreStop hook is in progress, skip creating the hard link of vineyard socket."
break
fi
# before mounting, store the rpc endpoint to a variable
# before creating the hard link of vineyard socket, 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
echo "write vineyard ipc socket and rpc endpoint to vineyard configuration YAML..."
write_yaml_config "$VINEYARD_RPC_ENDPOINT"
echo "check whether vineyard socket symlink is created..."
if [ ! -S $SOCKET_FILE ] && [ -S $MOUNT_DIR/vineyard.sock ]; then
echo "create a hard link of vineyard socket..."
ln $MOUNT_DIR/vineyard.sock $SOCKET_FILE
else
echo "$SOCKET_FILE exists."
fi
# wait for a minute so that the fuse mount point can be checked again
# wait for a minute so that the hard link of vineyard socket can be checked again
sleep 60
done
12 changes: 7 additions & 5 deletions python/vineyard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ def connect(*args, **kwargs):
Connect to vineyard by specified UNIX-domain socket or TCP endpoint.
If no arguments are provided and failed to resolve both the environment
variables :code:`VINEYARD_IPC_SOCKET`, :code:`VINEYARD_RPC_ENDPOINT`, and
:code:`VINEYARD_CONFIG`, it will launch a standalone vineyardd
server in the background and then connect to it.
variables :code:`VINEYARD_IPC_SOCKET`, :code:`VINEYARD_RPC_ENDPOINT`,
:code:`VINEYARD_CONFIG`, and the default configuration file
:code:`/var/run/vineyard-config.yaml`, it will launch a standalone
vineyardd server in the background and then connect to it.
The `connect()` method has various overloading:
Expand Down Expand Up @@ -400,6 +401,7 @@ def connect(*args, **kwargs):
and 'VINEYARD_IPC_SOCKET' not in os.environ
and 'VINEYARD_RPC_ENDPOINT' not in os.environ
and 'VINEYARD_CONFIG' not in os.environ
and not os.path.exists("/var/run/vineyard-config.yaml")
):
logger.info(
'No vineyard socket or endpoint is specified, '
Expand Down Expand Up @@ -427,7 +429,7 @@ def put(
E.g. 127.0.0.1:9600
VINEYARD_CONFIG:
Either be a path to a YAML configuration file or a path to a
directory containing the default config file `vineyard.yaml`.
directory containing the default config file `vineyard-config.yaml`.
The configuration file should be like:
Expand Down Expand Up @@ -492,7 +494,7 @@ def get(
E.g. 127.0.0.1:9600
VINEYARD_CONFIG:
Either be a path to a YAML configuration file or a path to a
directory containing the default config file `vineyard.yaml`.
directory containing the default config file `vineyard-config.yaml`.
The configuration file should be like:
Expand Down
14 changes: 7 additions & 7 deletions python/vineyard/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _parse_configuration(config) -> Tuple[Optional[str], Optional[str]]:
Parameters:
config: Path to a YAML configuration file or a directory containing
the default config file `vineyard.yaml`.
the default config file `vineyard-config.yaml`.
Returns:
(socket, endpoints): IPC socket path and RPC endpoints.
Expand All @@ -70,7 +70,7 @@ def _parse_configuration(config) -> Tuple[Optional[str], Optional[str]]:
return None, None

if os.path.isdir(config):
config = os.path.join(config, 'vineyard.yaml')
config = os.path.join(config, 'vineyard-config.yaml')
if not os.path.isfile(config):
return None, None

Expand Down Expand Up @@ -131,8 +131,8 @@ def __init__(
- `connect('hostname', port)`, which will try to establish an RPC connection.
- `connect(endpoint=('hostname', port))`, which will try to establish an RPC
connection.
- `connect(config='/path/to/vineyard.yaml')`, which will try to resolve the IPC
socket and RPC endpoints from the configuration file.
- `connect(config='/path/to/vineyard-config.yaml')`, which will try to
resolve the IPC socket and RPC endpoints from the configuration file.
Parameters:
socket: Optional, the path to the IPC socket, or RPC endpoints of format
Expand All @@ -147,10 +147,10 @@ def __init__(
is enabled.
config: Optional, can either be a path to a YAML configuration file or
a path to a directory containing the default config file
`vineyard.yaml`. Also, the environment variable
`vineyard-config.yaml`. Also, the environment variable
`VINEYARD_CONFIG` can be used to specify the
path to the configuration file. If not defined, the default
config file `/var/run/vineyard/config.yaml` will be used.
config file `/var/run/vineyard-config.yaml` will be used.
The content of the configuration file should has the following content:
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(
if not endpoint and not (host and port):
endpoint = os.getenv('VINEYARD_RPC_ENDPOINT', None)
if not config:
config = os.getenv('VINEYARD_CONFIG', '/var/run/vineyard/config.yaml')
config = os.getenv('VINEYARD_CONFIG', '/var/run/vineyard-config.yaml')
if endpoint:
if not isinstance(endpoint, (tuple, list)):
endpoint = endpoint.split(':')
Expand Down

0 comments on commit a0d38e3

Please sign in to comment.