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

NAS-133026 / 25.04 / Fix crash when handling job locks with invalid call arguments #15203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/middlewared/middlewared/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,12 @@ def check_pipe(self, pipe):
def get_lock_name(self):
lock_name = self.options.get('lock')
if callable(lock_name):
lock_name = lock_name(self.args)
try:
lock_name = lock_name(self.args)
except Exception:
self.middleware.logger.error("Error handling job lock", exc_info=True)
raise CallError("Error handling job lock. This is most likely caused by invalid call arguments.",
errno.EINVAL)
return lock_name

def set_id(self, id_):
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/apps/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async def convert_to_custom(self, job, app_name):
Str('version', default='latest'),
)
)
@job(lock=lambda args: f'app_create_{args[0]["app_name"]}')
@job(lock=lambda args: f'app_create_{args[0].get("app_name")}')
def do_create(self, job, data):
"""
Create an app with `app_name` using `catalog_app` with `train` and `version`.
Expand Down
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/pool_/dedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Config:
cli_namespace = 'storage.pool'

@api_method(DDTPruneArgs, DDTPruneResult)
@job(lock=lambda args: f'ddt_prune_{args[0]["pool_name"]}')
@job(lock=lambda args: f'ddt_prune_{args[0].get("pool_name")}')
async def ddt_prune(self, job, options):
"""
Prune DDT entries in pool `pool_name` based on the specified options.
Expand Down
Loading