From bbba6127b25c71bcd206c1edc10b93d6b5616bdc Mon Sep 17 00:00:00 2001 From: Nathan Matthews Date: Mon, 16 Oct 2023 16:28:25 +0000 Subject: [PATCH 1/4] feat(install): Adding vfs install path to install parameters Signed-off-by: Nathan Matthews --- .../installer/__init__.py | 10 ++++++ .../installer/install.sh | 31 +++++++++++++++++-- test/unit/install/test_install.py | 15 ++++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/deadline_worker_agent/installer/__init__.py b/src/deadline_worker_agent/installer/__init__.py index bac5e399..c36e39b8 100644 --- a/src/deadline_worker_agent/installer/__init__.py +++ b/src/deadline_worker_agent/installer/__init__.py @@ -13,6 +13,8 @@ "linux": Path(__file__).parent / "install.sh", } +VFS_DEFAULT_INSTALL_PATH = "/opt/fus3" + def install() -> None: """Installer entrypoint for the Amazon Deadline Cloud Worker Agent""" @@ -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] @@ -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 @@ -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 diff --git a/src/deadline_worker_agent/installer/install.sh b/src/deadline_worker_agent/installer/install.sh index c7a6f62d..17b2baa5 100755 --- a/src/deadline_worker_agent/installer/install.sh +++ b/src/deadline_worker_agent/installer/install.sh @@ -45,6 +45,7 @@ no_install_service="no" start_service="no" telemetry_opt_out="no" warning_lines=() +vfs_install_path="unset" usage() { @@ -52,6 +53,7 @@ usage() echo " [--region REGION] [--user USER]" echo " [--scripts-path SCRIPTS_PATH]" echo " [-y]" + echo " [--vfs_install_path VFS_INSTALL_PATH]" echo "" echo "Arguments" echo "---------" @@ -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 } @@ -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 @@ -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 ;; @@ -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 @@ -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 @@ -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 diff --git a/test/unit/install/test_install.py b/test/unit/install/test_install.py index e708e130..1df261fb 100644 --- a/test/unit/install/test_install.py +++ b/test/unit/install/test_install.py @@ -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 @@ -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, @@ -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 @@ -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 @@ -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)) From c04b7fc3ba6aeb3798dfa3a9ecaff9fa0cd03bc3 Mon Sep 17 00:00:00 2001 From: Nathan Matthews Date: Tue, 17 Oct 2023 18:54:34 +0000 Subject: [PATCH 2/4] Using /opt/deadline_vfs path instead of old fus3 path Signed-off-by: Nathan Matthews --- src/deadline_worker_agent/installer/__init__.py | 2 +- src/deadline_worker_agent/installer/install.sh | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/deadline_worker_agent/installer/__init__.py b/src/deadline_worker_agent/installer/__init__.py index c36e39b8..ba4d8c21 100644 --- a/src/deadline_worker_agent/installer/__init__.py +++ b/src/deadline_worker_agent/installer/__init__.py @@ -13,7 +13,7 @@ "linux": Path(__file__).parent / "install.sh", } -VFS_DEFAULT_INSTALL_PATH = "/opt/fus3" +VFS_DEFAULT_INSTALL_PATH = "/opt/deadline_vfs" def install() -> None: diff --git a/src/deadline_worker_agent/installer/install.sh b/src/deadline_worker_agent/installer/install.sh index 17b2baa5..31372c94 100755 --- a/src/deadline_worker_agent/installer/install.sh +++ b/src/deadline_worker_agent/installer/install.sh @@ -89,7 +89,7 @@ usage() 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" + echo " installed. If it is not specified, the default path /opt/deadline_vfs is used" exit 2 } @@ -213,7 +213,7 @@ if [[ ! -z "${job_group}" ]] && [[ ! "${job_group}" =~ ^[a-z_]([a-z0-9_-]{0,31}| fi if [[ "${vfs_install_path}" == "unset" ]]; then - vfs_install_path="/opt/fus3" + vfs_install_path="/opt/deadline_vfs" elif [[ ! -d "${vfs_install_path}" ]]; then echo "ERROR: The specified vfs install path is not found: \"${vfs_install_path}\"" usage @@ -221,12 +221,8 @@ 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 + echo "ERROR: Deadline vfs not found at \"${deadline_vfs_executable}\"." + exit 1 fi set -e fi @@ -382,7 +378,7 @@ Description=Amazon Deadline Cloud Worker Agent [Service] User=${wa_user} WorkingDirectory=${worker_agent_homedir} -Environment=AWS_REGION=$region AWS_DEFAULT_REGION=$region FUS3_PATH=$vfs_install_path +Environment=AWS_REGION=$region AWS_DEFAULT_REGION=$region FUS3_PATH=$vfs_install_path DEADLINE_VFS_PATH=$vfs_install_path ExecStart=$worker_agent_program Restart=on-failure From 6d05b4c31ad328b5f11c088e75bfe8c9b94a61d8 Mon Sep 17 00:00:00 2001 From: Nathan Matthews Date: Mon, 6 Nov 2023 23:54:02 +0000 Subject: [PATCH 3/4] Removing default value for vfs-install-path Signed-off-by: Nathan Matthews --- .../installer/__init__.py | 7 +--- .../installer/install.sh | 38 ++++++++++++------- test/unit/install/test_install.py | 4 +- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/deadline_worker_agent/installer/__init__.py b/src/deadline_worker_agent/installer/__init__.py index ba4d8c21..1f7b1843 100644 --- a/src/deadline_worker_agent/installer/__init__.py +++ b/src/deadline_worker_agent/installer/__init__.py @@ -13,8 +13,6 @@ "linux": Path(__file__).parent / "install.sh", } -VFS_DEFAULT_INSTALL_PATH = "/opt/deadline_vfs" - def install() -> None: """Installer entrypoint for the Amazon Deadline Cloud Worker Agent""" @@ -40,9 +38,9 @@ def install() -> None: args.user, "--scripts-path", str(scripts_path), - "--vfs-install-path", - args.vfs_install_path, ] + if args.vfs_install_path: + cmd += ["--vfs-install-path", args.vfs_install_path] if args.group: cmd += ["--group", args.group] if args.confirmed: @@ -145,7 +143,6 @@ def get_argument_parser() -> ArgumentParser: # pragma: no cover parser.add_argument( "--vfs-install-path", help="Absolute path for the install location of the deadline vfs.", - default=VFS_DEFAULT_INSTALL_PATH, ) return parser diff --git a/src/deadline_worker_agent/installer/install.sh b/src/deadline_worker_agent/installer/install.sh index 31372c94..3648b832 100755 --- a/src/deadline_worker_agent/installer/install.sh +++ b/src/deadline_worker_agent/installer/install.sh @@ -89,7 +89,7 @@ usage() 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/deadline_vfs is used" + echo " installed." exit 2 } @@ -212,19 +212,19 @@ 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/deadline_vfs" -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 "ERROR: Deadline vfs not found at \"${deadline_vfs_executable}\"." - exit 1 +if [[ "${vfs_install_path}" != "unset" ]]; then + if [[ ! -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 "ERROR: Deadline vfs not found at \"${deadline_vfs_executable}\"." + exit 1 + fi + set -e fi - set -e fi @@ -378,7 +378,19 @@ Description=Amazon Deadline Cloud Worker Agent [Service] User=${wa_user} WorkingDirectory=${worker_agent_homedir} +EOF + # Write VFS install directory if it's set + if [[ "${vfs_install_path}" != "unset" ]]; then + cat >> /etc/systemd/system/deadline-worker.service <> /etc/systemd/system/deadline-worker.service <> /etc/systemd/system/deadline-worker.service < Generator[MagicMock, None, None]: with patch.object(installer_mod, "run") as mock_subprocess_run: From 14c1a400665da384e28318cf80b1307f18c6ddf0 Mon Sep 17 00:00:00 2001 From: Nathan Matthews Date: Tue, 7 Nov 2023 17:59:09 +0000 Subject: [PATCH 4/4] Fixing usage line for install script Signed-off-by: Nathan Matthews --- src/deadline_worker_agent/installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deadline_worker_agent/installer/install.sh b/src/deadline_worker_agent/installer/install.sh index 3648b832..8121f395 100755 --- a/src/deadline_worker_agent/installer/install.sh +++ b/src/deadline_worker_agent/installer/install.sh @@ -53,7 +53,7 @@ usage() echo " [--region REGION] [--user USER]" echo " [--scripts-path SCRIPTS_PATH]" echo " [-y]" - echo " [--vfs_install_path VFS_INSTALL_PATH]" + echo " [--vfs-install-path VFS_INSTALL_PATH]" echo "" echo "Arguments" echo "---------"