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: run job attachment output upload as job user #495

Merged
merged 8 commits into from
Dec 5, 2024

Conversation

godobyte
Copy link
Contributor

@godobyte godobyte commented Nov 27, 2024

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

Worker Agent runs sync_input and sync_output callbacks to interact with customer s3 as worker agent user. This brings the following problem

  1. job user is a more suitable user to run the sync process
  2. sync_input and sync_output handling in session polluted the purpose of the class

What was the solution? (How)

Worker Agent is in the process of changing Job Attachment sync input and sync output to use attachment and manifest commands running as job user.

A sequel to #476

What is the impact of this change?

This is still in development and is under a feature flag.

How was this change tested?

  1. unit tests
  2. Locally set the feature flag, build and install whl files, run hatch deadline-worker-agent

Was this change documented?

It's currently only documented in the code docstring.

Is this a breaking change?

Not yet


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

…n, update attachment download to use python

Signed-off-by: Godot Bian <[email protected]>
@godobyte godobyte changed the title feat: implement sync output by attachment upload action running python feat: integrate with job attachment upload cli as a openjd action run Nov 27, 2024
@leongdl leongdl self-assigned this Nov 27, 2024
src/deadline_worker_agent/scheduler/session_queue.py Outdated Show resolved Hide resolved
src/deadline_worker_agent/scheduler/session_queue.py Outdated Show resolved Hide resolved
src/deadline_worker_agent/api_models.py Show resolved Hide resolved
src/deadline_worker_agent/sessions/session.py Outdated Show resolved Hide resolved
src/deadline_worker_agent/sessions/session.py Outdated Show resolved Hide resolved
src/deadline_worker_agent/sessions/session.py Show resolved Hide resolved
src/deadline_worker_agent/sessions/session.py Outdated Show resolved Hide resolved
src/deadline_worker_agent/sessions/session.py Show resolved Hide resolved


def upload(s3_root_uri: str, path_mapping_rules: str, manifests: list[str]) -> None:
s3_path = f"{os.environ.get("DEADLINE_FARM_ID")}/{os.environ.get("DEADLINE_QUEUE_ID")}/{os.environ.get("DEADLINE_JOB_ID")}/{os.environ.get("DEADLINE_STEP_ID")}/{os.environ.get("DEADLINE_TASK_ID")}/{os.environ.get("DEADLINE_SESSIONACTION_ID")}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Super nit, maybe a nice refactoring later to make this a helper function in Job Attachment APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted!

@godobyte
Copy link
Contributor Author

Quality Gate Failed Quality Gate failed

Failed conditions 8.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

This is because some tests added are under feature flag. The duplicate will be removed along with feature flag cleanup.

@godobyte godobyte marked this pull request as ready for review November 29, 2024 22:57
@godobyte godobyte requested a review from a team as a code owner November 29, 2024 22:57
StepActions as StepActions_2023_09,
)
from openjd.model import ParameterValue
from deadline.job_attachments.api.manifest import _manifest_snapshot
Copy link
Contributor Author

@godobyte godobyte Dec 4, 2024

Choose a reason for hiding this comment

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

This could cause an import error in windows, which need to be fixed before merging.

    Python could not import the service's module 
    Traceback (most recent call last):
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\__init__.py", line 6, in <module>
        from .installer import install
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\installer\__init__.py", line 15, in <module>
        from deadline_worker_agent.installer.win_installer import (
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\installer\win_installer.py", line 36, in <module>
        from ..windows.win_service import WorkerAgentWindowsService
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\windows\win_service.py", line 14, in <module>
        from deadline_worker_agent.startup.entrypoint import entrypoint
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\startup\entrypoint.py", line 24, in <module>
        from ..worker import Worker
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\worker.py", line 25, in <module>
        from .scheduler import WorkerScheduler
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\scheduler\__init__.py", line 4, in <module>
        from .session_queue import SessionActionQueue
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\scheduler\session_queue.py", line 29, in <module>
        from ..sessions.actions import (
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\sessions\actions\__init__.py", line 10, in <module>
        from .run_attachment_upload import AttachmentUploadAction
      File "C:\Program Files\Python311\Lib\site-packages\deadline_worker_agent\sessions\actions\run_attachment_upload.py", line 24, in <module>
        from deadline.job_attachments.api.manifest import _manifest_snapshot
      File "C:\Program Files\Python311\Lib\site-packages\deadline\job_attachments\api\__init__.py", line 5, in <module>
        from .attachment import attachment_download, attachment_upload
      File "C:\Program Files\Python311\Lib\site-packages\deadline\job_attachments\api\attachment.py", line 18, in <module>
        from deadline.client.cli._groups.click_logger import ClickLogger
      File "C:\Program Files\Python311\Lib\site-packages\deadline\client\cli\__init__.py", line 6, in <module>
        from ._deadline_cli import main
      File "C:\Program Files\Python311\Lib\site-packages\deadline\client\cli\_deadline_cli.py", line 14, in <module>
        from ._common import _PROMPT_WHEN_COMPLETE
      File "C:\Program Files\Python311\Lib\site-packages\deadline\client\cli\_common.py", line 31, in <module>
        sigint_handler = SigIntHandler()
                         ^^^^^^^^^^^^^^^
      File "C:\Program Files\Python311\Lib\site-packages\deadline\client\cli\_groups\_sigint_handler.py", line 19, in __new__
        signal.signal(signal.SIGINT, cls._instance._handle_sigint)
      File "C:\Program Files\Python311\Lib\signal.py", line 58, in signal
        handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ValueError: signal only works in main thread of the main interpreter
     

Kudos to @jericht for helping me find the error log in windows instance!

test/unit/sessions/actions/test_run_attachment_upload.py Outdated Show resolved Hide resolved
test/unit/sessions/actions/test_run_attachment_upload.py Outdated Show resolved Hide resolved
test/unit/sessions/test_session.py Outdated Show resolved Hide resolved
test/unit/sessions/test_session.py Outdated Show resolved Hide resolved
test/unit/sessions/test_session.py Outdated Show resolved Hide resolved
jusiskin
jusiskin previously approved these changes Dec 5, 2024
@jusiskin jusiskin changed the title feat: integrate with job attachment upload cli as a openjd action run feat: run job attachment output upload as job user Dec 5, 2024
Signed-off-by: Godot Bian <[email protected]>
Copy link

sonarqubecloud bot commented Dec 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
9.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@godobyte godobyte merged commit 678f29a into aws-deadline:mainline Dec 5, 2024
15 of 16 checks passed
@godobyte godobyte deleted the sync-output branch December 5, 2024 23:19
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.

3 participants