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: add os_user and os_env_vars for use by deadline vfs #104

Merged
merged 5 commits into from
Nov 14, 2023

Conversation

natmatn
Copy link
Contributor

@natmatn natmatn commented Nov 10, 2023

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

Queue credentials for the working session are stored and accessed in the deadline-cloud-worker-agent using the os_user's aws config file. This is used to create a boto3 session that deadline-cloud uses to sync inputs in the Copied method. This session can't be passed to the deadline_vfs subprocess so another path is needed to retrieve them.

What was the solution? (How)

Add os_user to the FileSystemPermissionSettings and an os_env_vars argument to AssetSync.sync_inputs(...) which can be used to configure the AWS config file path and AWS profile that is setup by the worker agent. If these details don't exist, the COPIED fallback is used in place of the VIRTUAL input sync method.

What is the impact of this change?

The Deadline worker agent will be able to configure the Deadline VFS to use the AWS credentials it vends for the queue and sync inputs for the job.

How was this change tested?

  • hatch run test
  • ran this on a worker and successfully completed both VIRTUAL and COPIED jobs

Was this change documented?

No

Is this a breaking change?

Yes, adding the new os_user required field requires a code change on the worker agent side. I've got another PR in the works to have the deadline-cloud-worker-agent provide this information from the session to thesync_inputs method

@natmatn natmatn requested a review from a team as a code owner November 10, 2023 00:26
src/deadline/job_attachments/fus3.py Outdated Show resolved Hide resolved
src/deadline/job_attachments/fus3.py Outdated Show resolved Hide resolved
@@ -327,6 +332,9 @@ def get_launch_environ(cls) -> dict:
] = f"{Fus3ProcessManager.find_fus3_link_dir()}{os.pathsep}{os.environ['PATH']}"
my_env["LD_LIBRARY_PATH"] = Fus3ProcessManager.get_library_path() # type: ignore[assignment]

my_env["AWS_CONFIG_FILE"] = str(Path(f"~{self._os_user}/.aws/config").expanduser())
Copy link
Contributor

@viknith viknith Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the path be f"~/{self._os_user}/.aws/config" with a slash after the tilde? Or does the _os_user variable come with a slash prepended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither, the expanduser method returns a new path with both ~ and ~user constructs expanded, so it provides the first slash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the caller control this through the os_env_vars argument?

src/deadline/job_attachments/fus3.py Outdated Show resolved Hide resolved
Signed-off-by: Nathan Matthews <[email protected]>
Signed-off-by: Nathan Matthews <[email protected]>
containing the AWS_PROFILE for use by the VFS

Signed-off-by: Nathan Matthews <[email protected]>
@natmatn natmatn force-pushed the natmatn/deadline_vfs_user branch from ecff747 to b8772d0 Compare November 14, 2023 01:50
@@ -400,6 +402,9 @@ def sync_inputs(
if (
attachments.fileSystem == JobAttachmentsFileSystem.VIRTUAL.value
and sys.platform != "win32"
and fs_permission_settings is not None
Copy link
Contributor

@mwiebe mwiebe Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question - does this mean if a user turns off the jobRunAsUser feature, the VFS will stop working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to turn off that feature? I thought it was a required field of the create-queue request

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is required, but users can opt-out by entering blank values for the jobRunAsUseruser and jobRunAsUsergroup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. Those fs_permission_settings are still using job-user when those fields are empty, which explains why my testing didn't encounter an issue here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline and we will address this in a follow-up fix.

src/deadline/job_attachments/fus3.py Show resolved Hide resolved
@@ -327,6 +332,9 @@ def get_launch_environ(cls) -> dict:
] = f"{Fus3ProcessManager.find_fus3_link_dir()}{os.pathsep}{os.environ['PATH']}"
my_env["LD_LIBRARY_PATH"] = Fus3ProcessManager.get_library_path() # type: ignore[assignment]

my_env["AWS_CONFIG_FILE"] = str(Path(f"~{self._os_user}/.aws/config").expanduser())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the caller control this through the os_env_vars argument?

os_group (str): The target operating system group for ownership.
dir_mode (int): The permission mode to be added to directories.
file_mode (int): The permission mode to be added to files.
"""

os_user: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this change? I believe it will have no effect if we are going with the solution to have the caller pass environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variables being passed only contain the AWS_PROFILE so I still need to get the Config file path on the other side

Copy link
Contributor

@jusiskin jusiskin Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed offline. While I maintain that a cleaner interface would be to have the worker agent pass AWS_CONFIG_FILE in the os_env_vars argument, it requires greater effort on the worker agent side and the code architecture there is not very conducive to this solution.

I'd like to revisit this later, but for now I'm okay merging this due to time constraints.

@jusiskin jusiskin changed the title fix: Adding os_user to FileSystemPermissionSettings for use by the deadline vfs feat: add os_user and os_env_vars for use by deadline vfs Nov 14, 2023
@jusiskin jusiskin added the enhancement New feature or request label Nov 14, 2023
@jusiskin jusiskin merged commit 7b3b3e6 into mainline Nov 14, 2023
17 checks passed
@jusiskin jusiskin deleted the natmatn/deadline_vfs_user branch November 14, 2023 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants