Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(install): Adding vfs install path to install parameters #58

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/deadline_worker_agent/installer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"linux": Path(__file__).parent / "install.sh",
}

VFS_DEFAULT_INSTALL_PATH = "/opt/fus3"
natmatn marked this conversation as resolved.
Show resolved Hide resolved


def install() -> None:
"""Installer entrypoint for the Amazon Deadline Cloud Worker Agent"""
Expand All @@ -38,6 +40,8 @@ def install() -> None:
args.user,
"--scripts-path",
str(scripts_path),
"--vfs-install-path",
args.vfs_install_path,
]
if args.group:
cmd += ["--group", args.group]
Expand Down Expand Up @@ -75,6 +79,7 @@ class ParsedCommandLineArguments(Namespace):
allow_shutdown: bool
install_service: bool
telemetry_opt_out: bool
vfs_install_path: str


def get_argument_parser() -> ArgumentParser: # pragma: no cover
Expand Down Expand Up @@ -137,5 +142,10 @@ def get_argument_parser() -> ArgumentParser: # pragma: no cover
action="store_true",
dest="confirmed",
)
parser.add_argument(
"--vfs-install-path",
help="Absolute path for the install location of the deadline vfs.",
default=VFS_DEFAULT_INSTALL_PATH,
)

return parser
31 changes: 29 additions & 2 deletions src/deadline_worker_agent/installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ no_install_service="no"
start_service="no"
telemetry_opt_out="no"
warning_lines=()
vfs_install_path="unset"

usage()
{
echo "Usage: install.sh --farm-id FARM_ID --fleet-id FLEET_ID"
echo " [--region REGION] [--user USER]"
echo " [--scripts-path SCRIPTS_PATH]"
echo " [-y]"
echo " [--vfs_install_path VFS_INSTALL_PATH]"
natmatn marked this conversation as resolved.
Show resolved Hide resolved
echo ""
echo "Arguments"
echo "---------"
Expand Down Expand Up @@ -85,6 +87,9 @@ usage()
echo " This option is ignored if --no-install-service is used."
echo " -y"
echo " Skips a confirmation prompt before performing the installation."
echo " --vfs-install-path VFS_INSTALL_PATH"
echo " An optional, absolute path to the directory that the Deadline Virtual File System (VFS) is"
echo " installed. If it is not specified, the default path /opt/fus3 is used"

exit 2
}
Expand All @@ -110,7 +115,7 @@ validate_deadline_id() {
}

# Validate arguments
PARSED_ARGUMENTS=$(getopt -n install.sh --longoptions farm-id:,fleet-id:,region:,user:,group:,scripts-path:,start,allow-shutdown,no-install-service,telemetry-opt-out -- "y" "$@")
PARSED_ARGUMENTS=$(getopt -n install.sh --longoptions farm-id:,fleet-id:,region:,user:,group:,scripts-path:,vfs-install-path:,start,allow-shutdown,no-install-service,telemetry-opt-out -- "y" "$@")
VALID_ARGUMENTS=$?
if [ "${VALID_ARGUMENTS}" != "0" ]; then
usage
Expand All @@ -129,6 +134,7 @@ do
--user) wa_user="$2" ; shift 2 ;;
--group) job_group="$2" ; shift 2 ;;
--scripts-path) scripts_path="$2" ; shift 2 ;;
--vfs-install-path) vfs_install_path="$2" ; shift 2 ;;
--allow-shutdown) allow_shutdown="yes" ; shift ;;
--no-install-service) no_install_service="yes" ; shift ;;
--telemetry-opt-out) telemetry_opt_out="yes" ; shift ;;
Expand Down Expand Up @@ -206,6 +212,26 @@ if [[ ! -z "${job_group}" ]] && [[ ! "${job_group}" =~ ^[a-z_]([a-z0-9_-]{0,31}|
usage
fi

if [[ "${vfs_install_path}" == "unset" ]]; then
vfs_install_path="/opt/fus3"
elif [[ ! -d "${vfs_install_path}" ]]; then
echo "ERROR: The specified vfs install path is not found: \"${vfs_install_path}\""
usage
else
set +e
deadline_vfs_executable="${vfs_install_path}"/bin/deadline_vfs
if [[ ! -f "${deadline_vfs_executable}" ]]; then
echo "Deadline vfs not found at \"${deadline_vfs_executable}\", using fus3 fallback."
fus3_executable="${vfs_install_path}"/bin/fus3
if [[ ! -f "${fus3_executable}" ]]; then
echo "ERROR: Could not find deadline vfs at install path \"${deadline_vfs_executable}\""
exit 1
fi
fi
set -e
fi


banner
echo

Expand All @@ -229,6 +255,7 @@ echo "Worker agent program path: ${client_library_program}"
echo "Allow worker agent shutdown: ${allow_shutdown}"
echo "Start systemd service: ${start_service}"
echo "Telemetry opt-out: ${telemetry_opt_out}"
echo "VFS install path: ${vfs_install_path}"

# Confirmation prompt
if [ -z "$confirm" ]; then
Expand Down Expand Up @@ -355,7 +382,7 @@ Description=Amazon Deadline Cloud Worker Agent
[Service]
User=${wa_user}
WorkingDirectory=${worker_agent_homedir}
Environment=AWS_REGION=$region AWS_DEFAULT_REGION=$region
Environment=AWS_REGION=$region AWS_DEFAULT_REGION=$region FUS3_PATH=$vfs_install_path
ExecStart=$worker_agent_program
Restart=on-failure

Expand Down
15 changes: 14 additions & 1 deletion test/unit/install/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

import pytest

from deadline_worker_agent.installer import ParsedCommandLineArguments, install
from deadline_worker_agent.installer import (
ParsedCommandLineArguments,
install,
VFS_DEFAULT_INSTALL_PATH,
)
from deadline_worker_agent import installer as installer_mod


Expand Down Expand Up @@ -82,6 +86,11 @@ def install_service() -> bool:
return True


@pytest.fixture
def vfs_install_path() -> str:
return VFS_DEFAULT_INSTALL_PATH


@pytest.fixture
def parsed_args(
farm_id: str,
Expand All @@ -94,6 +103,7 @@ def parsed_args(
allow_shutdown: bool,
install_service: bool,
telemetry_opt_out: bool,
vfs_install_path: str,
) -> ParsedCommandLineArguments:
parsed_args = ParsedCommandLineArguments()
parsed_args.farm_id = farm_id
Expand All @@ -106,6 +116,7 @@ def parsed_args(
parsed_args.allow_shutdown = allow_shutdown
parsed_args.install_service = install_service
parsed_args.telemetry_opt_out = telemetry_opt_out
parsed_args.vfs_install_path = vfs_install_path
return parsed_args


Expand Down Expand Up @@ -140,6 +151,8 @@ def expected_cmd(
parsed_args.user,
"--scripts-path",
sysconfig.get_path("scripts"),
"--vfs-install-path",
parsed_args.vfs_install_path,
]
if parsed_args.group is not None:
expected_cmd.extend(("--group", parsed_args.group))
Expand Down