Skip to content

Conversation

@edwards-aws
Copy link
Contributor

Fixes: aws-deadline/deadline-cloud-worker-agent#410

What was the problem/requirement? (What/Why)

Worker session cleanup encounters an error on windows when trying to delete the session directory

What was the solution? (How)

We were calling the Powershell removal command with start, which is a Powershell command, not an executable. So this would crash the session cleanup every time on Windows. We still need to run the cleanup with high priority. The real solution is to add the creation flag HIGH_PRIORITY_CLASS. I added the ability to add creation flags to the LoggerSubprocess.

There were also a handful of issues with the tests that I fixed.

  1. There was a test that was missed in the feat!: Adding support for redacted environment variable values through… #232 refactor
  2. Sometimes we need to run the Windows tests outside a virtual environment, so this changes the behaviour of one of the tests.

What is the impact of this change?

Sessions get cleaned up properly on Windows

How was this change tested?

I ran the regular and user impersonation tests on Windows and Linux. I also tested through the worker agent.

Session output before change:

==============================================
--------- Session Cleanup
==============================================
Deleting working directory: C:\ProgramData\Amazon\OpenJD\session-25c4f9f3fbe4414384b86d8981719dcfwejr0z_b
Running command start \"Powershell\" /high /wait /b powershell -Command Remove-Item -Recurse -Force "C:\ProgramData\Amazon\OpenJD\session-25c4f9f3fbe4414384b86d8981719dcfwejr0z_b\embedded_files25i1ifkd, C:\ProgramData\Amazon\OpenJD\session-25c4f9f3fbe4414384b86d8981719dcfwejr0z_b\tmpaqtoehpa.json, C:\ProgramData\Amazon\OpenJD\session-25c4f9f3fbe4414384b86d8981719dcfwejr0z_b\tmpdchwv2x0.json, C:\ProgramData\Amazon\OpenJD\session-25c4f9f3fbe4414384b86d8981719dcfwejr0z_b\tmpu0q0y6fq.json"
Process failed to start: [WinError 2] The system cannot find the file specified.

Session output after change:

==============================================
--------- Session Cleanup
==============================================
Deleting working directory: C:\Sessions\session-dafe77e5d47d4deebe7563582702e3d51zn_0jlm
Running command powershell -Command Remove-Item -Recurse -Force "C:\Sessions\session-dafe77e5d47d4deebe7563582702e3d51zn_0jlm\embedded_filestm6icqi3, C:\Sessions\session-dafe77e5d47d4deebe7563582702e3d51zn_0jlm\tmp1aeck0dm.json, C:\Sessions\session-dafe77e5d47d4deebe7563582702e3d51zn_0jlm\tmpd4684tq8.json, C:\Sessions\session-dafe77e5d47d4deebe7563582702e3d51zn_0jlm\tmpv02146v8.json"
Command started as pid: 8612
Output:
Process pid 8612 exited with code: 0 (unsigned) / 0x0 (hex)
  • Have you run the unit tests?
    yes

Was this change documented?

N/A

Is this a breaking change?

No

Does this change impact security?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@edwards-aws edwards-aws requested a review from a team as a code owner June 4, 2025 20:40
@edwards-aws edwards-aws force-pushed the clean_session_dir_windows branch from baad81a to 4f16852 Compare June 4, 2025 20:43
Signed-off-by: Cody Edwards <edwards@amazon.com>
@edwards-aws edwards-aws force-pushed the clean_session_dir_windows branch from 4f16852 to 5883569 Compare June 4, 2025 20:52
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 4, 2025

@edwards-aws edwards-aws merged commit f1f8933 into OpenJobDescription:mainline Jun 4, 2025
19 checks passed
@edwards-aws edwards-aws deleted the clean_session_dir_windows branch June 4, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Windows session clean-up fails to delete session folder

4 participants