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

add a project.lock_status endpoint to the service #2507

Closed
Panaetius opened this issue Dec 3, 2021 · 1 comment · Fixed by #2531
Closed

add a project.lock_status endpoint to the service #2507

Panaetius opened this issue Dec 3, 2021 · 1 comment · Fixed by #2531
Assignees

Comments

@Panaetius
Copy link
Member

Currently, long running operations like cache.migrate lock the project to other requests, raising an exception of a lock couldn't be acquired withing 15 seconds.

We should add a project.lock_status endpoint that can let clients know if a project is currently (write-)locked, returning a boolean.

The code for this could be something like

if "project_id" in self.context:
    project = self.cache.get_project(self.user, self.context["project_id"])
elif "git_url" in self.context:
    project = Project.get(
        (Project.user_id == self.user_data["user_id"]) & (Project.git_url == self.context["git_url"])
    )
else:
    raise Exception()

locked = True

try:
    with project.read_lock(timeout=0):
        locked=False
except (portalocker.LockException, portalocker.AlreadyLocked):
    locked = True

return locked

and of course without using the RenkuOperationMixin, similar to how renku.service.views.jobs doesn't use the mixin.

@m-alisafaee
Copy link
Contributor

Discuss with UI to make sure that the API here is what they want.

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 a pull request may close this issue.

2 participants