From 00d90e82dd5b37cb691484769f957f1586dcdc65 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 27 Jun 2024 10:19:45 -0400 Subject: [PATCH 01/10] Bump bwcOpenSearchVersion to 2.16.0 (#646) Signed-off-by: Craig Perkins --- sample-extension-plugin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-extension-plugin/build.gradle b/sample-extension-plugin/build.gradle index 2d5a2659..0bdc43f5 100644 --- a/sample-extension-plugin/build.gradle +++ b/sample-extension-plugin/build.gradle @@ -129,7 +129,7 @@ testClusters.integTest { } String baseName = "jobSchedulerBwcCluster" -String bwcOpenSearchVersion = "2.15.0" +String bwcOpenSearchVersion = "2.16.0" String bwcPluginVersion = bwcOpenSearchVersion + ".0" String bwcFilePath = "src/test/resources/bwc/job-scheduler/" bwcOpenSearchVersion += "-SNAPSHOT" From eb506e214726bcb1ae96823267cec8a3bdf168be Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 2 Jul 2024 13:05:47 -0400 Subject: [PATCH 02/10] Wrap interactions with .opendistro-job-scheduler-lock in ThreadContext.stashContext to ensure JS can read and write to the index (#347) * Make .opendistro-job-scheduler-lock a System Index Signed-off-by: Craig Perkins * Switch back to private Signed-off-by: Craig Perkins --------- Signed-off-by: Craig Perkins --- .../jobscheduler/spi/utils/LockService.java | 111 ++++++++++-------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java index 7651f7a0..4e75f525 100644 --- a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java +++ b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java @@ -8,6 +8,7 @@ */ package org.opensearch.jobscheduler.spi.utils; +import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.jobscheduler.spi.JobExecutionContext; import org.opensearch.jobscheduler.spi.LockModel; import org.opensearch.jobscheduler.spi.ScheduledJobParameter; @@ -77,20 +78,25 @@ public boolean lockIndexExist() { @VisibleForTesting void createLockIndex(ActionListener listener) { - if (lockIndexExist()) { - listener.onResponse(true); - } else { - final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping(lockMapping()); - client.admin() - .indices() - .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> { - if (exception instanceof ResourceAlreadyExistsException - || exception.getCause() instanceof ResourceAlreadyExistsException) { - listener.onResponse(true); - } else { - listener.onFailure(exception); - } - })); + try (ThreadContext.StoredContext ignore = client.threadPool().getThreadContext().stashContext()) { + if (lockIndexExist()) { + listener.onResponse(true); + } else { + final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping(lockMapping()); + client.admin() + .indices() + .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> { + if (exception instanceof ResourceAlreadyExistsException + || exception.getCause() instanceof ResourceAlreadyExistsException) { + listener.onResponse(true); + } else { + listener.onFailure(exception); + } + })); + } + } catch (Exception e) { + logger.error(e); + listener.onFailure(e); } } @@ -180,7 +186,7 @@ private boolean isLockReleasedOrExpired(final LockModel lock) { } private void updateLock(final LockModel updateLock, ActionListener listener) { - try { + try (ThreadContext.StoredContext ignore = client.threadPool().getThreadContext().stashContext()) { UpdateRequest updateRequest = new UpdateRequest().index(LOCK_INDEX_NAME) .id(updateLock.getLockId()) .setIfSeqNo(updateLock.getSeqNo()) @@ -212,11 +218,14 @@ private void updateLock(final LockModel updateLock, ActionListener li } catch (IOException e) { logger.error("IOException occurred updating lock.", e); listener.onResponse(null); + } catch (Exception e) { + logger.error(e); + listener.onFailure(e); } } private void createLock(final LockModel tempLock, ActionListener listener) { - try { + try (ThreadContext.StoredContext ignore = client.threadPool().getThreadContext().stashContext()) { final IndexRequest request = new IndexRequest(LOCK_INDEX_NAME).id(tempLock.getLockId()) .source(tempLock.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)) .setIfSeqNo(SequenceNumbers.UNASSIGNED_SEQ_NO) @@ -243,25 +252,30 @@ private void createLock(final LockModel tempLock, ActionListener list } public void findLock(final String lockId, ActionListener listener) { - GetRequest getRequest = new GetRequest(LOCK_INDEX_NAME).id(lockId); - client.get(getRequest, ActionListener.wrap(response -> { - if (!response.isExists()) { - listener.onResponse(null); - } else { - try { - XContentParser parser = XContentType.JSON.xContent() - .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, response.getSourceAsString()); - parser.nextToken(); - listener.onResponse(LockModel.parse(parser, response.getSeqNo(), response.getPrimaryTerm())); - } catch (IOException e) { - logger.error("IOException occurred finding lock", e); + try (ThreadContext.StoredContext ignore = client.threadPool().getThreadContext().stashContext()) { + GetRequest getRequest = new GetRequest(LOCK_INDEX_NAME).id(lockId); + client.get(getRequest, ActionListener.wrap(response -> { + if (!response.isExists()) { listener.onResponse(null); + } else { + try { + XContentParser parser = XContentType.JSON.xContent() + .createParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, response.getSourceAsString()); + parser.nextToken(); + listener.onResponse(LockModel.parse(parser, response.getSeqNo(), response.getPrimaryTerm())); + } catch (IOException e) { + logger.error("IOException occurred finding lock", e); + listener.onResponse(null); + } } - } - }, exception -> { - logger.error("Exception occurred finding lock", exception); - listener.onFailure(exception); - })); + }, exception -> { + logger.error("Exception occurred finding lock", exception); + listener.onFailure(exception); + })); + } catch (Exception e) { + logger.error(e); + listener.onFailure(e); + } } /** @@ -293,19 +307,24 @@ public void release(final LockModel lock, ActionListener listener) { * or not the delete was successful */ public void deleteLock(final String lockId, ActionListener listener) { - DeleteRequest deleteRequest = new DeleteRequest(LOCK_INDEX_NAME).id(lockId); - client.delete(deleteRequest, ActionListener.wrap(response -> { - listener.onResponse( - response.getResult() == DocWriteResponse.Result.DELETED || response.getResult() == DocWriteResponse.Result.NOT_FOUND - ); - }, exception -> { - if (exception instanceof IndexNotFoundException || exception.getCause() instanceof IndexNotFoundException) { - logger.debug("Index is not found to delete lock. {}", exception.getMessage()); - listener.onResponse(true); - } else { - listener.onFailure(exception); - } - })); + try (ThreadContext.StoredContext ignore = client.threadPool().getThreadContext().stashContext()) { + DeleteRequest deleteRequest = new DeleteRequest(LOCK_INDEX_NAME).id(lockId); + client.delete(deleteRequest, ActionListener.wrap(response -> { + listener.onResponse( + response.getResult() == DocWriteResponse.Result.DELETED || response.getResult() == DocWriteResponse.Result.NOT_FOUND + ); + }, exception -> { + if (exception instanceof IndexNotFoundException || exception.getCause() instanceof IndexNotFoundException) { + logger.debug("Index is not found to delete lock. {}", exception.getMessage()); + listener.onResponse(true); + } else { + listener.onFailure(exception); + } + })); + } catch (Exception e) { + logger.error(e); + listener.onFailure(e); + } } /** From 72d61ac9b3c84557ad24c121d9985c13af23d660 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 10 Jul 2024 11:59:48 -0400 Subject: [PATCH 03/10] Fix checkout action failure (#650) Signed-off-by: Craig Perkins --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4719543b..0707644b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,10 @@ jobs: # need to switch to root so that github actions can install runner binary on container without permission issues. options: --user root + # Allow using Node16 actions + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true + steps: - name: Checkout job-scheduler uses: actions/checkout@v2 From a6837a219e3f6c6ce05c6f7abd84608e22db1917 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 11 Jul 2024 15:59:54 -0500 Subject: [PATCH 04/10] Update PULL_REQUEST_TEMPLATE to include an API spec change in the checklist. (#649) Signed-off-by: dblock --- .github/PULL_REQUEST_TEMPLATE.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d7981b51..254e075d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,15 +1,16 @@ ### Description [Describe what this change achieves] - -### Issues Resolved -[List any issues this PR will resolve] - + +### Related Issues +Resolves #[Issue number to be closed when this PR is merged] + + ### Check List - [ ] New functionality includes testing. - - [ ] All tests pass - [ ] New functionality has been documented. - - [ ] New functionality has javadoc added -- [ ] Commits are signed per the DCO using --signoff +- [ ] API changes companion pull request [created](https://github.com/opensearch-project/opensearch-api-specification/blob/main/DEVELOPER_GUIDE.md). +- [ ] Commits are signed per the DCO using `--signoff`. +- [ ] Public documentation issue/PR [created](https://github.com/opensearch-project/documentation-website/issues/new/choose). 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](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). +For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/job-scheduler/blob/main/CONTRIBUTING.md#developer-certificate-of-origin). From 704473cdf50312744e014240e9bdbc2ae27eed77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 14:53:48 -0400 Subject: [PATCH 05/10] dependabot: bump org.gradle.test-retry from 1.5.9 to 1.5.10 (#653) Bumps org.gradle.test-retry from 1.5.9 to 1.5.10. --- updated-dependencies: - dependency-name: org.gradle.test-retry dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- spi/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spi/build.gradle b/spi/build.gradle index 51b18d06..5d22842a 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -11,7 +11,7 @@ plugins { id 'jacoco' id 'maven-publish' id 'signing' - id "org.gradle.test-retry" version "1.5.9" + id "org.gradle.test-retry" version "1.5.10" } apply plugin: 'opensearch.java' From de0eb3b92a80aa43a82d5dcf006bdd446246523f Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Tue, 23 Jul 2024 14:59:42 -0700 Subject: [PATCH 06/10] Release 2.16.0 release notes (#655) Signed-off-by: Prudhvi Godithi --- ...pensearch-job-scheduler.release-notes-2.15.0.0.md | 4 ++-- ...pensearch-job-scheduler.release-notes-2.16.0.0.md | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 release-notes/opensearch-job-scheduler.release-notes-2.16.0.0.md diff --git a/release-notes/opensearch-job-scheduler.release-notes-2.15.0.0.md b/release-notes/opensearch-job-scheduler.release-notes-2.15.0.0.md index 7f35d006..68767e4d 100644 --- a/release-notes/opensearch-job-scheduler.release-notes-2.15.0.0.md +++ b/release-notes/opensearch-job-scheduler.release-notes-2.15.0.0.md @@ -1,6 +1,6 @@ -## Version 2.14.0.0 +## Version 2.15.0.0 -Compatible with OpenSearch 2.14.0 +Compatible with OpenSearch 2.15.0 ### Maintenance * Increment version to 2.15.0 ([#626](https://github.com/opensearch-project/job-scheduler/pull/626)). diff --git a/release-notes/opensearch-job-scheduler.release-notes-2.16.0.0.md b/release-notes/opensearch-job-scheduler.release-notes-2.16.0.0.md new file mode 100644 index 00000000..043c3277 --- /dev/null +++ b/release-notes/opensearch-job-scheduler.release-notes-2.16.0.0.md @@ -0,0 +1,12 @@ +## Version 2.16.0.0 + +Compatible with OpenSearch 2.16.0 + +### Maintenance +* Increment version to 2.16.0 ([#638](https://github.com/opensearch-project/job-scheduler/pull/638)). + +### Infrastructure +* Fix checkout action failure [(#650)](https://github.com/opensearch-project/job-scheduler/pull/650) [(#651)](https://github.com/opensearch-project/job-scheduler/pull/651). + +### Enhancements +* Wrap interactions with `.opendistro-job-scheduler-lock` in `ThreadContext.stashContext` to ensure JS can read and write to the index [(#347)](https://github.com/opensearch-project/job-scheduler/pull/347) [(#647)](https://github.com/opensearch-project/job-scheduler/pull/647). \ No newline at end of file From 4888ab2a2ac322f998f19b143750bd23d83feeb4 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Wed, 31 Jul 2024 16:26:22 -0700 Subject: [PATCH 07/10] Fix system index compatibility with v1 templates (#658) Signed-off-by: Daniel Widdis --- .../org/opensearch/jobscheduler/spi/utils/LockService.java | 6 +++++- .../opensearch/jobscheduler/utils/JobDetailsService.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java index 4e75f525..19c5fb58 100644 --- a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java +++ b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java @@ -26,6 +26,7 @@ import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentFactory; @@ -82,7 +83,10 @@ void createLockIndex(ActionListener listener) { if (lockIndexExist()) { listener.onResponse(true); } else { - final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping(lockMapping()); + final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping( + lockMapping(), + (MediaType) XContentType.JSON + ); client.admin() .indices() .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> { diff --git a/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java b/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java index 3af7cb3d..4a112e1e 100644 --- a/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java +++ b/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java @@ -30,6 +30,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.extensions.action.ExtensionProxyAction; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.index.IndexNotFoundException; @@ -293,7 +294,10 @@ void createJobDetailsIndex(ActionListener listener) { if (jobDetailsIndexExist()) { listener.onResponse(true); } else { - CreateIndexRequest request = new CreateIndexRequest(JOB_DETAILS_INDEX_NAME).mapping(jobDetailsMapping()); + CreateIndexRequest request = new CreateIndexRequest(JOB_DETAILS_INDEX_NAME).mapping( + jobDetailsMapping(), + (MediaType) XContentType.JSON + ); client.admin() .indices() .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> { From a22145048b0e5357af4b0576b9be8287cdbfb0c8 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 2 Aug 2024 22:53:05 -0400 Subject: [PATCH 08/10] Bump bwcOpenSearchVersion to 2.17.0 (#661) Signed-off-by: Craig Perkins --- sample-extension-plugin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-extension-plugin/build.gradle b/sample-extension-plugin/build.gradle index 0bdc43f5..32760c5b 100644 --- a/sample-extension-plugin/build.gradle +++ b/sample-extension-plugin/build.gradle @@ -129,7 +129,7 @@ testClusters.integTest { } String baseName = "jobSchedulerBwcCluster" -String bwcOpenSearchVersion = "2.16.0" +String bwcOpenSearchVersion = "2.17.0" String bwcPluginVersion = bwcOpenSearchVersion + ".0" String bwcFilePath = "src/test/resources/bwc/job-scheduler/" bwcOpenSearchVersion += "-SNAPSHOT" From 496d64e7a91ee7d65aa32eeea520bf99a23ab6ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:58:31 -0400 Subject: [PATCH 09/10] dependabot: bump com.google.googlejavaformat:google-java-format (#663) Bumps [com.google.googlejavaformat:google-java-format](https://github.com/google/google-java-format) from 1.22.0 to 1.23.0. - [Release notes](https://github.com/google/google-java-format/releases) - [Commits](https://github.com/google/google-java-format/compare/v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: com.google.googlejavaformat:google-java-format dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4483aef9..f578d14b 100644 --- a/build.gradle +++ b/build.gradle @@ -165,7 +165,7 @@ dependencies { testImplementation group: 'org.mockito', name: 'mockito-core', version: "${versions.mockito}" javaRestTestImplementation project.sourceSets.main.runtimeClasspath //spotless - implementation('com.google.googlejavaformat:google-java-format:1.22.0') { + implementation('com.google.googlejavaformat:google-java-format:1.23.0') { exclude group: 'com.google.guava' } } From 021fea5503f13d5fb088b7fb4132b27791575aa2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:53:39 -0400 Subject: [PATCH 10/10] dependabot: bump org.slf4j:slf4j-api from 2.0.13 to 2.0.16 (#666) Bumps org.slf4j:slf4j-api from 2.0.13 to 2.0.16. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- spi/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spi/build.gradle b/spi/build.gradle index 5d22842a..bbcf1c26 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -44,7 +44,7 @@ jacocoTestReport { } check.dependsOn jacocoTestReport -def slf4j_version_of_cronutils = "2.0.13" +def slf4j_version_of_cronutils = "2.0.16" dependencies { compileOnly "org.opensearch:opensearch:${opensearch_version}" // slf4j is the runtime dependency of cron-utils