Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-security-ci
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Aug 1, 2024
2 parents 5ca6f88 + f02bb01 commit 2b0f89b
Show file tree
Hide file tree
Showing 38 changed files with 1,429 additions and 81 deletions.
15 changes: 11 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
*Issue #, if available:*
### Description
[Describe what this change achieves]

*Description of changes:*
### Related Issues
Resolves #[Issue number to be closed when this PR is merged]
<!-- List any other related issues here -->

*CheckList:*
- [ ] Commits are signed per the DCO using --signoff
### Check List
- [ ] New functionality includes testing.
- [ ] New functionality has been documented.
- [ ] 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/index-management/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).
2 changes: 1 addition & 1 deletion .github/workflows/bwc-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 17
java-version: 21
# index-management
- name: Checkout Branch
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-security-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 17
java-version: 21
- name: Checkout Branch
uses: actions/checkout@v2
- name: Build Index Management
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ jobs:
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
echo "::add-mask::$SONATYPE_USERNAME"
echo "::add-mask::$SONATYPE_PASSWORD"
./gradlew publishPluginZipPublicationToSnapshotsRepository
./gradlew publishPluginZipPublicationToSnapshotsRepository
./gradlew publishShadowPublicationToSnapshotsRepository
2 changes: 2 additions & 0 deletions .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
push:
branches:
- "**"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
Get-CI-Image-Tag:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/security-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
push:
branches:
- "**"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
Get-CI-Image-Tag:
Expand All @@ -31,7 +33,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 17
java-version: 21
# index-management
- name: Checkout Branch
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-and-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- "**"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
Get-CI-Image-Tag:
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ publishing {
}
}

tasks.generatePomFileForPluginZipPublication.dependsOn publishNebulaPublicationToMavenLocal

plugins.withId('java') {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Version 2.16.0.0 2024-07-29

Compatible with OpenSearch 2.16.0

### Maintenance
* Increment version to 2.16.0-SNAPSHOT ([#1187](https://github.com/opensearch-project/index-management/pull/1187))
* Add publish in spi build.gradle ([#1207](https://github.com/opensearch-project/index-management/pull/1207))
* Fix github action ([#1208](https://github.com/opensearch-project/index-management/pull/1208))
58 changes: 58 additions & 0 deletions spi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'
apply plugin: 'idea'
apply plugin: 'maven-publish'

ext {
projectSubstitutions = [:]
Expand Down Expand Up @@ -83,6 +84,11 @@ tasks.register("sourcesJar", Jar) {
from sourceSets.main.allSource
}

task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

test {
doFirst {
test.classpath -= project.files(project.tasks.named('shadowJar'))
Expand All @@ -103,3 +109,55 @@ check.dependsOn integTest
testClusters.javaRestTest {
testDistribution = 'INTEG_TEST'
}

publishing {
repositories {
maven {
name = 'staging'
url = "${rootProject.buildDir}/local-staging-repo"
}
maven {
name = "Snapshots"
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
publications {
shadow(MavenPublication) {
project.shadow.component(it)

artifact sourcesJar
artifact javadocJar

pom {
name = "OpenSearch Index Management SPI"
packaging = "jar"
url = "https://github.com/opensearch-project/index-management"
description = "OpenSearch Index Management SPI"
scm {
connection = "scm:git@github.com:opensearch-project/index-management.git"
developerConnection = "scm:git@github.com:opensearch-project/index-management.git"
url = "git@github.com:opensearch-project/index-management.git"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/index-management"
}
}
}
}
}

gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS)
gradle.startParameter.setLogLevel(LogLevel.DEBUG)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.apache.logging.log4j.Logger
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.core.common.io.stream.Writeable
import org.opensearch.indexmanagement.spi.indexstatemanagement.metrics.IndexManagementActionsMetrics
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.ManagedIndexMetaData
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepContext
import org.opensearch.indexmanagement.spi.indexstatemanagement.model.StepMetaData
Expand All @@ -27,12 +28,109 @@ abstract class Step(val name: String, val isSafeToDisableOn: Boolean = true) {

abstract suspend fun execute(): Step

fun postExecute(logger: Logger): Step {
fun postExecute(
logger: Logger,
indexManagementActionMetrics: IndexManagementActionsMetrics,
step: Step,
startingManagedIndexMetaData: ManagedIndexMetaData,
): Step {
logger.info("Finished executing $name for ${context?.metadata?.index}")
val updatedStepMetaData = step.getUpdatedManagedIndexMetadata(startingManagedIndexMetaData)
emitTelemetry(indexManagementActionMetrics, updatedStepMetaData, logger)
this.context = null
return this
}

private fun emitTelemetry(
indexManagementActionMetrics: IndexManagementActionsMetrics,
updatedStepMetaData: ManagedIndexMetaData,
logger: Logger,
) {
when (context?.metadata?.actionMetaData?.name) {
IndexManagementActionsMetrics.ROLLOVER -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.ROLLOVER,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.FORCE_MERGE -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.FORCE_MERGE,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.DELETE -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.DELETE,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.REPLICA_COUNT -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.REPLICA_COUNT,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.TRANSITION -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.TRANSITION,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.NOTIFICATION -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.NOTIFICATION,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.CLOSE -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.CLOSE,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.SET_INDEX_PRIORITY -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.SET_INDEX_PRIORITY, // problem in test
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.OPEN -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.OPEN,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.MOVE_SHARD -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.MOVE_SHARD,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.SET_READ_ONLY -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.SET_READ_ONLY,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.SHRINK -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.SHRINK,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.SNAPSHOT -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.SNAPSHOT,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.ALIAS_ACTION -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.ALIAS_ACTION,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

IndexManagementActionsMetrics.ALLOCATION -> indexManagementActionMetrics.getActionMetrics(
IndexManagementActionsMetrics.ALLOCATION,
)
?.emitMetrics(context!!, indexManagementActionMetrics, updatedStepMetaData.stepMetaData)

else -> {
logger.info(
"Action Metrics is not supported for this action [%s]",
context?.metadata?.actionMetaData?.name,
)
}
}
}

abstract fun getUpdatedManagedIndexMetadata(currentMetadata: ManagedIndexMetaData): ManagedIndexMetaData

abstract fun isIdempotent(): Boolean
Expand Down
Loading

0 comments on commit 2b0f89b

Please sign in to comment.