From 390de24dcce72e8c0737f2ae28d92445280a1c09 Mon Sep 17 00:00:00 2001 From: DawoudSheraz Date: Fri, 15 Mar 2024 12:38:55 +0500 Subject: [PATCH 1/2] fix: ensure mounted xblocks are installed as expected --- tutor/commands/jobs.py | 2 +- ...ed-edx-platform.sh => mounted-directories.sh} | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) rename tutor/templates/jobs/init/{mounted-edx-platform.sh => mounted-directories.sh} (50%) diff --git a/tutor/commands/jobs.py b/tutor/commands/jobs.py index f6795fefcd..3d8e845ae5 100644 --- a/tutor/commands/jobs.py +++ b/tutor/commands/jobs.py @@ -45,7 +45,7 @@ def _add_core_init_tasks() -> None: hooks.Filters.CLI_DO_INIT_TASKS.add_item( ( "lms", - env.read_core_template_file("jobs", "init", "mounted-edx-platform.sh"), + env.read_core_template_file("jobs", "init", "mounted-directories.sh"), ), # If edx-platform is mounted, then we may need to perform some setup # before other initialization scripts can be run. diff --git a/tutor/templates/jobs/init/mounted-edx-platform.sh b/tutor/templates/jobs/init/mounted-directories.sh similarity index 50% rename from tutor/templates/jobs/init/mounted-edx-platform.sh rename to tutor/templates/jobs/init/mounted-directories.sh index 9516654ff5..8f78df9b4f 100644 --- a/tutor/templates/jobs/init/mounted-edx-platform.sh +++ b/tutor/templates/jobs/init/mounted-directories.sh @@ -1,7 +1,23 @@ +# The initialization job contains various re-install operations needed to be done +# on mounted directories (edx-platform, /mnt/*xblock) +# 1. /mnt/*xblock +# Whenever xblocks are mounted, during the image build time, they are copied over to container and +# installed. This results in egg_info generation for the mounted xblocks. However, the egg_info is not carried +# over to host. When the containers are launched, the host directories without egg_info are mounted on runtime +# and disappear from pip list. +# 2. edx-platform # When a new local copy of edx-platform is bind-mounted, certain build # artifacts from the openedx image's edx-platform directory are lost. # We regenerate them here. + +for mounted_xblock in /mnt/*xblock/; do + if ! ls "$mounted_xblock"*.egg-info >/dev/null 2>&1; then + echo "Unable to locate egg-info in $mounted_xblock" + pip install -e $mounted_xblock + fi +done + if [ -f /openedx/edx-platform/bindmount-canary ] ; then # If this file exists, then edx-platform has not been bind-mounted, # so no build artifacts need to be regenerated. From 2acef736c0f367afcc4c5b75bd552d9a2fefd8ec Mon Sep 17 00:00:00 2001 From: DawoudSheraz Date: Fri, 15 Mar 2024 16:35:34 +0500 Subject: [PATCH 2/2] chore: update checks --- .../20240315_163331_dawoud.sheraz_tutor_997.md | 1 + .../templates/jobs/init/mounted-directories.sh | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 changelog.d/20240315_163331_dawoud.sheraz_tutor_997.md diff --git a/changelog.d/20240315_163331_dawoud.sheraz_tutor_997.md b/changelog.d/20240315_163331_dawoud.sheraz_tutor_997.md new file mode 100644 index 0000000000..e72ce4912d --- /dev/null +++ b/changelog.d/20240315_163331_dawoud.sheraz_tutor_997.md @@ -0,0 +1 @@ +- [BugFix] Ensure mounted installable packages are installed as expected upon initialization. (by @dawoudsheraz) diff --git a/tutor/templates/jobs/init/mounted-directories.sh b/tutor/templates/jobs/init/mounted-directories.sh index 8f78df9b4f..e10dc7b7c9 100644 --- a/tutor/templates/jobs/init/mounted-directories.sh +++ b/tutor/templates/jobs/init/mounted-directories.sh @@ -1,20 +1,21 @@ # The initialization job contains various re-install operations needed to be done -# on mounted directories (edx-platform, /mnt/*xblock) -# 1. /mnt/*xblock -# Whenever xblocks are mounted, during the image build time, they are copied over to container and -# installed. This results in egg_info generation for the mounted xblocks. However, the egg_info is not carried +# on mounted directories (edx-platform, /mnt/*xblock, /mnt/) +# 1. /mnt/* +# Whenever xblocks or other installable packages are mounted, during the image build, they are copied over to container +# and installed. This results in egg_info generation for the mounted directories. However, the egg_info is not carried # over to host. When the containers are launched, the host directories without egg_info are mounted on runtime # and disappear from pip list. +# # 2. edx-platform # When a new local copy of edx-platform is bind-mounted, certain build # artifacts from the openedx image's edx-platform directory are lost. # We regenerate them here. -for mounted_xblock in /mnt/*xblock/; do - if ! ls "$mounted_xblock"*.egg-info >/dev/null 2>&1; then - echo "Unable to locate egg-info in $mounted_xblock" - pip install -e $mounted_xblock +for mounted_dir in /mnt/*; do + if [ -f $mounted_dir/setup.py ] && ! ls $mounted_dir/*.egg-info >/dev/null 2>&1 ; then + echo "Unable to locate egg-info in $mounted_dir" + pip install -e $mounted_dir fi done