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

V2.4.2 #505

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 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)
Expand Down
10 changes: 9 additions & 1 deletion client/autotest_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from werkzeug.exceptions import HTTPException
import os
import sys
import time
import rq
import json
import io
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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}

Expand Down
13 changes: 6 additions & 7 deletions server/autotest_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -366,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))

Expand Down
Loading