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: allow local session logs to be turned off in worker tests #155

Merged
merged 1 commit into from
Oct 15, 2024
Merged
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
11 changes: 11 additions & 0 deletions src/deadline_test_fixtures/deadline/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class DeadlineWorkerConfiguration:
start_service: bool = False
no_install_service: bool = False
service_model_path: str | None = None
no_local_session_logs: str | None = None

"""Mapping of files to copy from host environment to worker environment"""
file_mappings: list[tuple[str, str]] | None = None
Expand Down Expand Up @@ -460,6 +461,12 @@ def configure_worker_common(self, *, config: DeadlineWorkerConfiguration) -> str
f"Copy-Item -Path ~\\.aws\\* -Destination C:\\Users\\{config.job_user}\\.aws\\models -Recurse"
)

if config.no_local_session_logs:
cmds.append(
"[System.Environment]::SetEnvironmentVariable('DEADLINE_WORKER_LOCAL_SESSION_LOGS', 'false', [System.EnvironmentVariableTarget]::Machine); "
"$env:DEADLINE_WORKER_LOCAL_SESSION_LOGS = [System.Environment]::GetEnvironmentVariable('DEADLINE_WORKER_LOCAL_SESSION_LOGS','Machine')",
)

if os.environ.get("DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE"):
LOG.info(
f"Using DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE: {os.environ.get('DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE')}"
Expand Down Expand Up @@ -667,6 +674,10 @@ def configure_agent_user_environment(
f"runuser -l {config.agent_user} -s /bin/bash -c 'aws configure add-model --service-model file://{config.service_model_path}'"
)

if config.no_local_session_logs:
cmds.append(
f"runuser -l {config.agent_user} -s /bin/bash -c 'echo export DEADLINE_WORKER_LOCAL_SESSION_LOGS=false >> ~/.bashrc'",
)
if os.environ.get("DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE"):
LOG.info(
f"Using DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE: {os.environ.get('DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE')}"
Expand Down