From b2948922602f370a25dad1dc205a992f5db68c48 Mon Sep 17 00:00:00 2001 From: Samuel Maldonado Date: Fri, 22 Mar 2024 10:22:32 -0400 Subject: [PATCH 1/3] user separate sticky bit command when cleaning up test directories (#491) --- server/autotest_server/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 6f2ee12d..046b565a 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -218,6 +218,7 @@ def _run_test_specs( preexec_fn=set_rlimits_before_test, universal_newlines=True, env={**os.environ, **env_vars, **env}, + executable="/bin/bash", ) try: settings_json = json.dumps({**settings, "test_data": test_data}) @@ -254,10 +255,13 @@ def _clear_working_directory(tests_path: str, test_username: str) -> None: Run commands that clear the tests_path working directory """ if test_username != getpass.getuser(): - chmod_cmd = f"sudo -u {test_username} -- bash -c 'chmod -Rf -t ugo+rwX {tests_path}'" + sticky_cmd = f"sudo -u {test_username} -- bash -c 'chmod -Rf -t {tests_path}'" + chmod_cmd = f"sudo -u {test_username} -- bash -c 'chmod -Rf ugo+rwX {tests_path}'" else: - chmod_cmd = f"chmod -Rf -t ugo+rwX {tests_path}" + sticky_cmd = f"chmod -Rf -t {tests_path}" + chmod_cmd = f"chmod -Rf ugo+rwX {tests_path}" + subprocess.run(sticky_cmd, shell=True) subprocess.run(chmod_cmd, shell=True) # be careful not to remove the tests_path dir itself since we have to From 561412cdbea6c0feb9dee5016cb765ff22da8782 Mon Sep 17 00:00:00 2001 From: David Liu Date: Tue, 2 Apr 2024 14:46:32 -0400 Subject: [PATCH 2/3] Set _env_status earlier when updating settings (#499) * Set _env_status earlier when updating settings * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- Changelog.md | 1 + client/autotest_client/__init__.py | 10 +++++++++- server/autotest_server/__init__.py | 5 ----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 7b1efc4c..642a80c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented here. ## [v2.4.1] - Fix bug that prevented copies of instructor directories from being deleted (#483) - Add STACK_ROOT to containers as well as notes in readme (#484) +- Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499) ## [v2.4.0] - Fix bug that prevented test results from being returned when a feedback file could not be found (#458) diff --git a/client/autotest_client/__init__.py b/client/autotest_client/__init__.py index dc2ea3a8..87455aae 100644 --- a/client/autotest_client/__init__.py +++ b/client/autotest_client/__init__.py @@ -2,6 +2,7 @@ from werkzeug.exceptions import HTTPException import os import sys +import time import rq import json import io @@ -108,6 +109,11 @@ def _update_settings(settings_id, user): if error: abort(make_response(jsonify(message=error), 422)) + test_settings["_user"] = user + test_settings["_last_access"] = int(time.time()) + test_settings["_env_status"] = "setup" + REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps(test_settings)) + queue = rq.Queue("settings", connection=REDIS_CONNECTION) data = {"user": user, "settings_id": settings_id, "test_settings": test_settings, "file_url": file_url} queue.enqueue_call( @@ -198,7 +204,9 @@ def settings(settings_id, **_kw): @authorize def create_settings(user): settings_id = REDIS_CONNECTION.incr("autotest:settings_id") - REDIS_CONNECTION.hset("autotest:settings", key=settings_id, value=json.dumps({"_user": user})) + REDIS_CONNECTION.hset( + "autotest:settings", key=settings_id, value=json.dumps({"_user": user, "_env_status": "setup"}) + ) _update_settings(settings_id, user) return {"settings_id": settings_id} diff --git a/server/autotest_server/__init__.py b/server/autotest_server/__init__.py index 046b565a..88524c26 100644 --- a/server/autotest_server/__init__.py +++ b/server/autotest_server/__init__.py @@ -370,11 +370,6 @@ def ignore_missing_dir_error( def update_test_settings(user, settings_id, test_settings, file_url): - test_settings["_user"] = user - test_settings["_last_access"] = int(time.time()) - test_settings["_env_status"] = "setup" - redis_connection().hset("autotest:settings", key=settings_id, value=json.dumps(test_settings)) - try: settings_dir = os.path.join(TEST_SCRIPT_DIR, str(settings_id)) From 2e8097f6bd9431664c44a046548ac149b7cdd654 Mon Sep 17 00:00:00 2001 From: Samuel Maldonado Date: Wed, 3 Apr 2024 15:38:49 -0400 Subject: [PATCH 3/3] Changelog: update changelog --- Changelog.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 642a80c2..de8bbbf4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,12 @@ # CHANGELOG All notable changes to this project will be documented here. +## [v2.4.2] +- Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499) + ## [v2.4.1] - Fix bug that prevented copies of instructor directories from being deleted (#483) - Add STACK_ROOT to containers as well as notes in readme (#484) -- Ensure _env_status is updated to "setup" earlier when a request to update test settings is made (#499) ## [v2.4.0] - Fix bug that prevented test results from being returned when a feedback file could not be found (#458)