Skip to content

Conversation

Jeremydupras
Copy link
Contributor

@Jeremydupras Jeremydupras commented Jul 24, 2025

Description

This Api gets all the locks in the job-scheduler plugin. The intention is to use this information to find the currently executing jobs by using the active locks. This API will allow the user to see whether a job is currently executing, has an active/expired lock or does not have a lock. Additionally, users will be able to look for specific lock by adding the lockID as a path parameter. API call examples are below.

-> Gets all of the locks within Job Scheduler

GET /_plugins/_job_scheduler/api/locks

-> Gets a specific lock
LOCK_ID_DELIMITER = "-"
lockID = jobIndexName + LOCK_ID_DELIMITR + jobId

GET /_plugins/_job_scheduler/api/locks/lockID

Example return JSON

{
  "total_locks": 3,
  "locks": {
    ".scheduler_sample_extension-jobid2": {
      "job_index_name": ".scheduler_sample_extension",
      "job_id": "jobid2",
      "lock_aquired_time": "2025-07-25T17:18:58.000Z",
      "lock_duration_seconds": 120,
      "released": false
    },
    ".scheduler_sample_extension-jobid1": {
      "job_index_name": ".scheduler_sample_extension",
      "job_id": "jobid1",
      "lock_aquired_time": "2025-07-25T17:17:58.000Z",
      "lock_duration_seconds": 120,
      "released": false
    },
    ".scheduler_sample_extension-jobid3": {
      "job_index_name": ".scheduler_sample_extension",
      "job_id": "jobid3",
      "lock_aquired_time": "2025-07-25T17:18:58.000Z",
      "lock_duration_seconds": 120,
      "released": false
    }
  }
}

Related Issues

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Jeremy Dupras and others added 22 commits July 11, 2025 15:05
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

❌ Patch coverage is 11.76471% with 120 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.43%. Comparing base (cf681a4) to head (3b61338).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r/transport/action/TransportGetAllLocksAction.java 0.00% 87 Missing ⚠️
...scheduler/transport/response/GetLocksResponse.java 0.00% 23 Missing ⚠️
...obscheduler/transport/request/GetLocksRequest.java 23.07% 10 Missing ⚠️

❌ Your project status has failed because the head coverage (31.43%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #802      +/-   ##
============================================
- Coverage     33.45%   31.43%   -2.02%     
- Complexity      143      150       +7     
============================================
  Files            29       34       +5     
  Lines          1393     1527     +134     
  Branches        133      137       +4     
============================================
+ Hits            466      480      +14     
- Misses          890     1010     +120     
  Partials         37       37              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Jeremy Dupras <[email protected]>
Jeremy Dupras added 3 commits July 25, 2025 10:20
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
@Jeremydupras
Copy link
Contributor Author

Changes to SampleJobRunner have been added to ensure that the doc is updated before the lock is released.

Signed-off-by: Craig Perkins <[email protected]>
Jeremydupras and others added 2 commits July 29, 2025 15:27
Move ser/de logic to LockModel
Signed-off-by: Jeremy Dupras <[email protected]>
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @Jeremydupras !

@cwperks
Copy link
Member

cwperks commented Jul 30, 2025

Codecov will be fixed by #800

@cwperks cwperks merged commit e88586e into opensearch-project:main Jul 30, 2025
13 of 15 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in Engineering Effectiveness Board Jul 30, 2025
Jeremydupras added a commit to Jeremydupras/job-scheduler that referenced this pull request Aug 20, 2025
…arch-project#802)

* adding active jobs by lock info

Signed-off-by: Jeremy Dupras <[email protected]>

* adding active jobs and tests

Signed-off-by: Jeremy Dupras <[email protected]>

* changing to ActionListener

Signed-off-by: Jeremy Dupras <[email protected]>

* fixing failing multinode test and format errors

Signed-off-by: Jeremy Dupras <[email protected]>

* correcting test

Signed-off-by: Jeremy Dupras <[email protected]>

* updating test

Signed-off-by: Jeremy Dupras <[email protected]>

* updating test

Signed-off-by: Jeremy Dupras <[email protected]>

* trying test fix

Signed-off-by: Jeremy Dupras <[email protected]>

* updating test

Signed-off-by: Jeremy Dupras <[email protected]>

* rerunning tests

Signed-off-by: Jeremy Dupras <[email protected]>

* removing getFirst()

Signed-off-by: Jeremy Dupras <[email protected]>

* removing lock search

Signed-off-by: Jeremy Dupras <[email protected]>

* remiving client

Signed-off-by: Jeremy Dupras <[email protected]>

* adding lock duration

Signed-off-by: Jeremy Dupras <[email protected]>

* adding getLocks API

Signed-off-by: Jeremy Dupras <[email protected]>

* adding test for lock transport action

Signed-off-by: Jeremy Dupras <[email protected]>

* adding tests

Signed-off-by: Jeremy Dupras <[email protected]>

* commmiting changes

Signed-off-by: Jeremy Dupras <[email protected]>

* adding lockid path parameter

Signed-off-by: Jeremy Dupras <[email protected]>

* adding tests

Signed-off-by: Jeremy Dupras <[email protected]>

* Empty commit message

Signed-off-by: Jeremy Dupras <[email protected]>

* renaming, reformatting response JSON, test changes

Signed-off-by: Jeremy Dupras <[email protected]>

* changing name in variable

Signed-off-by: Jeremy Dupras <[email protected]>

* fixing test timing

Signed-off-by: Jeremy Dupras <[email protected]>

* Move ser/de logic to LockModel

Signed-off-by: Craig Perkins <[email protected]>

* adressing comments

Signed-off-by: Jeremy Dupras <[email protected]>

---------

Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Co-authored-by: Jeremy Dupras <[email protected]>
Co-authored-by: Craig Perkins <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants