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

Initiating Nautobot jobs, next-2.0 rebase #270

Merged
merged 29 commits into from
Mar 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c17166c
copy init-jobs changes fom #224 with rebase to next-2.0 branch
Sep 26, 2023
67d545d
Rebased PR for next-2.0 branch, had some trouble with fork
Sep 26, 2023
e01dbe6
Correct change fragment, #270 will replace #224, and closes #223
Sep 26, 2023
99e4512
Add kwargs for get_jobs() that allows user-specified header items to …
Sep 26, 2023
0d623ef
Minor update
Sep 26, 2023
0f28144
Catch job_result.result == "FAILURE"
Sep 26, 2023
9d99ca7
run black
Sep 26, 2023
4d0d877
pydocstyle, flake8 fixes
Sep 26, 2023
fe07fc3
black formatter
Sep 26, 2023
1c8da1a
pylint
Sep 26, 2023
3fc453a
remove runnable references
Sep 26, 2023
d7e4ccc
reuse existing user instance (dispatch.user)
Sep 27, 2023
1423b8c
typo correction for dispatcher.user
Sep 27, 2023
50725bb
Replace list comp with generator
smk4664 Sep 29, 2023
42e1931
Add init-job-form nautobot subcommand
Oct 31, 2023
f074f92
flake8 fix, catch explicit exception
Oct 31, 2023
6910196
Remove block response, leaving testing commented
Oct 31, 2023
98c2db3
pylint8 fixes
Oct 31, 2023
9a259a5
CI history expired, re-running checks
Feb 5, 2024
8dd56fe
pylint CI fixes: W1113, R0914, C0301
Feb 5, 2024
195c888
Black code formatter
Feb 6, 2024
28c1d95
pylint ignore too-many-locals for init_job
Feb 6, 2024
cb26441
Replace execute_job with enqueue_job, which is correct Nautobot 2.x p…
Feb 6, 2024
64ed936
Fix missing variable
Feb 6, 2024
00eb275
Update breadcrumb changes
Feb 6, 2024
7470ec8
Add max iterations for waiting on job to enter ready state in the dat…
Feb 6, 2024
0ab7e78
Rename `init_job` subcommand to `run_job`
Feb 6, 2024
875ca64
Update error for initiated job status failure state
Feb 7, 2024
e6c14c6
Rub Black formatter
Feb 7, 2024
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
Prev Previous commit
Next Next commit
Add max iterations for waiting on job to enter ready state in the dat…
…abase
meganerd committed Feb 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7470ec861458a86e523e452ede9a7ef5e13af6cd
5 changes: 5 additions & 0 deletions nautobot_chatops/workers/nautobot.py
Original file line number Diff line number Diff line change
@@ -1206,7 +1206,12 @@ def init_job(dispatcher, *args, job_name: str = "", json_string_kwargs: str = ""
)

# Wait on the job to finish
max_wait_iterations = 60
while job_result.status not in JobResultStatusChoices.READY_STATES:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We may want something to drop out of this loop after enough time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We may want something to drop out of this loop after enough time?

Addressed in 7470ec8

max_wait_iterations -= 1
if not max_wait_iterations:
dispatcher.send_error(f"The requested job {job_name} failed to reach ready state.")
return (CommandStatusChoices.STATUS_FAILED, f'Job "{job_name}" failed to reach ready state.')
time.sleep(1)
job_result.refresh_from_db()