From 3851e34915ffd16da2f47f6b632794c303124df2 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Mon, 2 Dec 2024 21:20:56 -0800 Subject: [PATCH 1/5] fix bug Observability plugin calling createIndex from onNodeStarted method before cluster state is ready (waits for the cluster state to be ready) Signed-off-by: YANGDB --- .../observability/index/ObservabilityIndex.kt | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt index 1c4ccfa4f..f3f45a125 100644 --- a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt +++ b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt @@ -96,32 +96,41 @@ internal object ObservabilityIndex : LifecycleListener() { */ @Suppress("TooGenericExceptionCaught") private fun createIndex() { - if (!isIndexExists(INDEX_NAME)) { - val classLoader = ObservabilityIndex::class.java.classLoader - val indexMappingSource = classLoader.getResource(OBSERVABILITY_MAPPING_FILE_NAME)?.readText()!! - val indexSettingsSource = classLoader.getResource(OBSERVABILITY_SETTINGS_FILE_NAME)?.readText()!! - val request = CreateIndexRequest(INDEX_NAME) - .mapping(indexMappingSource, XContentType.YAML) - .settings(indexSettingsSource, XContentType.YAML) - try { - val actionFuture = client.admin().indices().create(request) - val response = actionFuture.actionGet(PluginSettings.operationTimeoutMs) - if (response.isAcknowledged) { - log.info("$LOG_PREFIX:Index $INDEX_NAME creation Acknowledged") - reindexNotebooks() - } else { - error("$LOG_PREFIX:Index $INDEX_NAME creation not Acknowledged") - } - } catch (exception: ResourceAlreadyExistsException) { - log.warn("message: ${exception.message}") - } catch (exception: Exception) { - if (exception.cause !is ResourceAlreadyExistsException) { - throw exception + try { + // wait for the cluster here until it will finish managed node election + while (clusterService.state().blocks().hasGlobalBlockWithStatus(RestStatus.SERVICE_UNAVAILABLE)) { + log.info("Wait for cluster to be available ..."); + TimeUnit.SECONDS.sleep(1); + } + if (!isIndexExists(INDEX_NAME)) { + val classLoader = ObservabilityIndex::class.java.classLoader + val indexMappingSource = classLoader.getResource(OBSERVABILITY_MAPPING_FILE_NAME)?.readText()!! + val indexSettingsSource = classLoader.getResource(OBSERVABILITY_SETTINGS_FILE_NAME)?.readText()!! + val request = CreateIndexRequest(INDEX_NAME) + .mapping(indexMappingSource, XContentType.YAML) + .settings(indexSettingsSource, XContentType.YAML) + try { + val actionFuture = client.admin().indices().create(request) + val response = actionFuture.actionGet(PluginSettings.operationTimeoutMs) + if (response.isAcknowledged) { + log.info("$LOG_PREFIX:Index $INDEX_NAME creation Acknowledged") + reindexNotebooks() + } else { + error("$LOG_PREFIX:Index $INDEX_NAME creation not Acknowledged") + } + } catch (exception: ResourceAlreadyExistsException) { + log.warn("message: ${exception.message}") + } catch (exception: Exception) { + if (exception.cause !is ResourceAlreadyExistsException) { + throw exception + } } + this.mappingsUpdated = true + } else if (!this.mappingsUpdated) { + updateMappings() } - this.mappingsUpdated = true - } else if (!this.mappingsUpdated) { - updateMappings() + } catch (exception: Exception) { + log.error("Unexpected exception while initializing node $exception", exception); } } From 5c1b8b252c3a711ea2911522cf76ae6cfd3b5983 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Mon, 2 Dec 2024 21:37:52 -0800 Subject: [PATCH 2/5] update klint format Signed-off-by: YANGDB --- .../opensearch/observability/index/ObservabilityIndex.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt index f3f45a125..5645cccb1 100644 --- a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt +++ b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt @@ -99,8 +99,8 @@ internal object ObservabilityIndex : LifecycleListener() { try { // wait for the cluster here until it will finish managed node election while (clusterService.state().blocks().hasGlobalBlockWithStatus(RestStatus.SERVICE_UNAVAILABLE)) { - log.info("Wait for cluster to be available ..."); - TimeUnit.SECONDS.sleep(1); + log.info("Wait for cluster to be available ...") + TimeUnit.SECONDS.sleep(1) } if (!isIndexExists(INDEX_NAME)) { val classLoader = ObservabilityIndex::class.java.classLoader @@ -130,7 +130,7 @@ internal object ObservabilityIndex : LifecycleListener() { updateMappings() } } catch (exception: Exception) { - log.error("Unexpected exception while initializing node $exception", exception); + log.error("Unexpected exception while initializing node $exception", exception) } } From 2537f48fa1316bb9bc118d1978c9f542555a38e1 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Mon, 2 Dec 2024 21:44:03 -0800 Subject: [PATCH 3/5] fix deprecated version of `actions/upload-artifact: v1` see https://github.blog/changelog/2024-02-13-deprecation-notice-v1-and-v2-of-the-artifact-actions/ Signed-off-by: YANGDB --- .../opensearch-observability-test-and-build-workflow.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/opensearch-observability-test-and-build-workflow.yml b/.github/workflows/opensearch-observability-test-and-build-workflow.yml index 9a7fb6ee0..1a2bb1100 100644 --- a/.github/workflows/opensearch-observability-test-and-build-workflow.yml +++ b/.github/workflows/opensearch-observability-test-and-build-workflow.yml @@ -11,6 +11,8 @@ jobs: build-linux: needs: Get-CI-Image-Tag strategy: + # Run all jobs + fail-fast: false matrix: java: [11, 17, 21] runs-on: ubuntu-latest @@ -56,7 +58,7 @@ jobs: cp -r ./build/distributions/*.zip opensearch-observability-builds/ - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3-node20 with: name: opensearch-observability-ubuntu-latest path: opensearch-observability-builds @@ -88,7 +90,7 @@ jobs: cp -r ./build/distributions/*.zip opensearch-observability-builds/ - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3-node20 with: name: opensearch-observability-${{ matrix.os }} path: opensearch-observability-builds From 595e5ab6a5ccac5aad606214c0395b75d1da0642 Mon Sep 17 00:00:00 2001 From: YANGDB Date: Mon, 2 Dec 2024 22:31:36 -0800 Subject: [PATCH 4/5] fix deprecated version of github actions Signed-off-by: YANGDB --- ...h-observability-test-and-build-workflow.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/opensearch-observability-test-and-build-workflow.yml b/.github/workflows/opensearch-observability-test-and-build-workflow.yml index 1a2bb1100..194838f22 100644 --- a/.github/workflows/opensearch-observability-test-and-build-workflow.yml +++ b/.github/workflows/opensearch-observability-test-and-build-workflow.yml @@ -20,20 +20,23 @@ jobs: # using the same image which is used by opensearch-build team to build the OpenSearch Distribution # this image tag is subject to change as more dependencies and updates will arrive over time image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} - # need to switch to root so that github actions can install runner binary on container without permission issues. - options: --user root + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true steps: - - uses: actions/checkout@v1 + - name: Run start commands + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} + - uses: actions/checkout@v4 + - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} - + distribution: 'temurin' + - name: Run Backwards Compatibility Tests run: | echo "Running backwards compatibility tests ..." @@ -73,11 +76,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'temurin' java-version: ${{ matrix.java }} - name: Build with Gradle From d9964beb88a760d0569cd9febc16c04497a82e9f Mon Sep 17 00:00:00 2001 From: YANGDB Date: Wed, 4 Dec 2024 13:07:36 -0800 Subject: [PATCH 5/5] fix deprecated version of github actions (v4) Signed-off-by: YANGDB --- .../opensearch-observability-test-and-build-workflow.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/opensearch-observability-test-and-build-workflow.yml b/.github/workflows/opensearch-observability-test-and-build-workflow.yml index 194838f22..fc5f16f09 100644 --- a/.github/workflows/opensearch-observability-test-and-build-workflow.yml +++ b/.github/workflows/opensearch-observability-test-and-build-workflow.yml @@ -22,9 +22,6 @@ jobs: image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }} options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} - env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true - steps: - name: Run start commands run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} @@ -61,7 +58,7 @@ jobs: cp -r ./build/distributions/*.zip opensearch-observability-builds/ - name: Upload Artifacts - uses: actions/upload-artifact@v3-node20 + uses: actions/upload-artifact@v4 with: name: opensearch-observability-ubuntu-latest path: opensearch-observability-builds @@ -94,7 +91,7 @@ jobs: cp -r ./build/distributions/*.zip opensearch-observability-builds/ - name: Upload Artifacts - uses: actions/upload-artifact@v3-node20 + uses: actions/upload-artifact@v4 with: name: opensearch-observability-${{ matrix.os }} path: opensearch-observability-builds