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

[AUTO] Incremented version to 2.16.1. #708

Open
wants to merge 11 commits into
base: 2.16
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
pull_request:
branches:
- "*"
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
Get-CI-Image-Tag:
Expand Down Expand Up @@ -57,6 +59,7 @@ jobs:
- 11
- 17
- 21
- 23
name: Build and Test
runs-on: windows-latest

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
buildscript {
ext {
opensearch_group = "org.opensearch"
opensearch_version = System.getProperty("opensearch.version", "2.16.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "2.18.1-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
kotlin_version = System.getProperty("kotlin.version", "1.8.21")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
12 changes: 12 additions & 0 deletions release-notes/opensearch-common-utils.release-notes-2.16.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Version 2.16.0.0 2024-07-25

Compatible with OpenSearch 2.16.0

### Maintenance
* Increment version to 2.16.0-SNAPSHOT ([#688](https://github.com/opensearch-project/common-utils/pull/688))

### Enhancements
* [Backport 2.x] Add support for remote monitors ([#694](https://github.com/opensearch-project/common-utils/pull/694))

### Documentation
* Added 2.16.0.0 release notes. ([#700](https://github.com/opensearch-project/common-utils/pull/700))
16 changes: 16 additions & 0 deletions release-notes/opensearch-common-utils.release-notes-2.17.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Version 2.17.0.0 2024-09-03

Compatible with OpenSearch 2.17.0

### Maintenance
* Fixed Common-Utils CIs: ([#703](https://github.com/opensearch-project/common-utils/pull/703))

### Bug Fixes
* Added missing ctx variables ([#710](https://github.com/opensearch-project/common-utils/pull/710))
* Changed the names of security actions for Alerting Comments feature ([#724](https://github.com/opensearch-project/common-utils/pull/724))

### Enhancements
* Updated pull request template to include API spec change in checklist ([#696](https://github.com/opensearch-project/common-utils/pull/696))

### Documentation
* Added 2.17.0.0 release notes ([#727](https://github.com/opensearch-project/common-utils/pull/727))
13 changes: 13 additions & 0 deletions release-notes/opensearch-common-utils.release-notes-2.18.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Version 2.18.0.0 2024-10-28

Compatible with OpenSearch 2.18.0

### Maintenance
* Increment version to 2.18.0-SNAPSHOT ([#729](https://github.com/opensearch-project/common-utils/pull/729))
* Update Gradle to 8.10.2 ([#746](https://github.com/opensearch-project/common-utils/pull/746))

### Enhancements
* changes to support dynamic deletion of doc-level monitor query indices ([#734](https://github.com/opensearch-project/common-utils/pull/734))

### Documentation
* Added 2.18.0.0 release notes. ([#750](https://github.com/opensearch-project/common-utils/pull/750))
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ object AlertingActions {
const val SUBSCRIBE_FINDINGS_ACTION_NAME = "cluster:admin/opensearch/alerting/findings/subscribe"
const val GET_MONITOR_ACTION_NAME = "cluster:admin/opendistro/alerting/monitor/get"
const val SEARCH_MONITORS_ACTION_NAME = "cluster:admin/opendistro/alerting/monitor/search"
const val INDEX_COMMENT_ACTION_NAME = "cluster:admin/opensearch/alerting/alerts/comments/write"
const val SEARCH_COMMENTS_ACTION_NAME = "cluster:admin/opensearch/alerting/alerts/comments/search"
const val DELETE_COMMENT_ACTION_NAME = "cluster:admin/opensearch/alerting/alerts/comments/delete"
const val INDEX_COMMENT_ACTION_NAME = "cluster:admin/opensearch/alerting/comments/write"
const val SEARCH_COMMENTS_ACTION_NAME = "cluster:admin/opensearch/alerting/comments/search"
const val DELETE_COMMENT_ACTION_NAME = "cluster:admin/opensearch/alerting/comments/delete"

@JvmField
val INDEX_MONITOR_ACTION_TYPE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ data class BucketLevelTrigger(
NAME_FIELD to name,
SEVERITY_FIELD to severity,
ACTIONS_FIELD to actions.map { it.asTemplateArg() },
PARENT_BUCKET_PATH to getParentBucketPath()
PARENT_BUCKET_PATH to getParentBucketPath(),
CONDITION_FIELD to mapOf(
SCRIPT_FIELD to mapOf(
SOURCE_FIELD to bucketSelector.script.idOrCode,
LANG_FIELD to bucketSelector.script.lang
)
)
)
}

Expand All @@ -81,6 +87,9 @@ data class BucketLevelTrigger(
const val BUCKET_LEVEL_TRIGGER_FIELD = "bucket_level_trigger"
const val CONDITION_FIELD = "condition"
const val PARENT_BUCKET_PATH = "parentBucketPath"
const val SCRIPT_FIELD = "script"
const val SOURCE_FIELD = "source"
const val LANG_FIELD = "lang"

val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
Trigger::class.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class DocLevelMonitorInput(
sin.readList(::DocLevelQuery) // docLevelQueries
)

fun asTemplateArg(): Map<String, Any?> {
override fun asTemplateArg(): Map<String, Any> {
return mapOf(
DESCRIPTION_FIELD to description,
INDICES_FIELD to indices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ data class DocumentLevelTrigger(
ID_FIELD to id,
NAME_FIELD to name,
SEVERITY_FIELD to severity,
ACTIONS_FIELD to actions.map { it.asTemplateArg() }
ACTIONS_FIELD to actions.map { it.asTemplateArg() },
CONDITION_FIELD to mapOf(
SCRIPT_FIELD to mapOf(
SOURCE_FIELD to condition.idOrCode,
LANG_FIELD to condition.lang
)
)
)
}

Expand All @@ -78,6 +84,8 @@ data class DocumentLevelTrigger(
const val CONDITION_FIELD = "condition"
const val SCRIPT_FIELD = "script"
const val QUERY_IDS_FIELD = "query_ids"
const val SOURCE_FIELD = "source"
const val LANG_FIELD = "lang"

val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
Trigger::class.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ interface Input : BaseModel {
}

fun name(): String

/** Returns a representation of the schedule suitable for passing into painless and mustache scripts. */
fun asTemplateArg(): Map<String, Any> = emptyMap()
}
26 changes: 24 additions & 2 deletions src/main/kotlin/org/opensearch/commons/alerting/model/Monitor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ data class Monitor(
val triggers: List<Trigger>,
val uiMetadata: Map<String, Any>,
val dataSources: DataSources = DataSources(),
val deleteQueryIndexInEveryRun: Boolean? = false,
val owner: String? = "alerting"
) : ScheduledJob {

Expand Down Expand Up @@ -110,6 +111,7 @@ data class Monitor(
} else {
DataSources()
},
deleteQueryIndexInEveryRun = sin.readOptionalBoolean(),
owner = sin.readOptionalString()
)

Expand All @@ -127,8 +129,18 @@ data class Monitor(
}

/** Returns a representation of the monitor suitable for passing into painless and mustache scripts. */
fun asTemplateArg(): Map<String, Any> {
return mapOf(_ID to id, _VERSION to version, NAME_FIELD to name, ENABLED_FIELD to enabled)
fun asTemplateArg(): Map<String, Any?> {
return mapOf(
_ID to id,
_VERSION to version,
NAME_FIELD to name,
ENABLED_FIELD to enabled,
MONITOR_TYPE_FIELD to monitorType.toString(),
ENABLED_TIME_FIELD to enabledTime?.toEpochMilli(),
LAST_UPDATE_TIME_FIELD to lastUpdateTime.toEpochMilli(),
SCHEDULE_FIELD to schedule.asTemplateArg(),
INPUTS_FIELD to inputs.map { it.asTemplateArg() }
)
}

fun toXContentWithUser(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
Expand Down Expand Up @@ -159,6 +171,7 @@ data class Monitor(
.optionalTimeField(LAST_UPDATE_TIME_FIELD, lastUpdateTime)
if (uiMetadata.isNotEmpty()) builder.field(UI_METADATA_FIELD, uiMetadata)
builder.field(DATA_SOURCES_FIELD, dataSources)
builder.field(DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD, deleteQueryIndexInEveryRun)
builder.field(OWNER_FIELD, owner)
if (params.paramAsBoolean("with_type", false)) builder.endObject()
return builder.endObject()
Expand Down Expand Up @@ -210,6 +223,7 @@ data class Monitor(
out.writeMap(uiMetadata)
out.writeBoolean(dataSources != null) // for backward compatibility with pre-existing monitors which don't have datasources field
dataSources.writeTo(out)
out.writeOptionalBoolean(deleteQueryIndexInEveryRun)
out.writeOptionalString(owner)
}

Expand All @@ -230,6 +244,7 @@ data class Monitor(
const val UI_METADATA_FIELD = "ui_metadata"
const val DATA_SOURCES_FIELD = "data_sources"
const val ENABLED_TIME_FIELD = "enabled_time"
const val DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD = "delete_query_index_in_every_run"
const val OWNER_FIELD = "owner"
val MONITOR_TYPE_PATTERN = Pattern.compile("[a-zA-Z0-9_]{5,25}")

Expand Down Expand Up @@ -258,6 +273,7 @@ data class Monitor(
val triggers: MutableList<Trigger> = mutableListOf()
val inputs: MutableList<Input> = mutableListOf()
var dataSources = DataSources()
var deleteQueryIndexInEveryRun = false
var owner = "alerting"

XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)
Expand Down Expand Up @@ -311,6 +327,11 @@ data class Monitor(
} else {
DataSources.parse(xcp)
}
DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD -> deleteQueryIndexInEveryRun = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) {
deleteQueryIndexInEveryRun
} else {
xcp.booleanValue()
}
OWNER_FIELD -> owner = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) owner else xcp.text()
else -> {
xcp.skipChildren()
Expand Down Expand Up @@ -338,6 +359,7 @@ data class Monitor(
triggers.toList(),
uiMetadata,
dataSources,
deleteQueryIndexInEveryRun,
owner
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ data class QueryLevelTrigger(
ID_FIELD to id,
NAME_FIELD to name,
SEVERITY_FIELD to severity,
ACTIONS_FIELD to actions.map { it.asTemplateArg() }
ACTIONS_FIELD to actions.map { it.asTemplateArg() },
CONDITION_FIELD to mapOf(
SCRIPT_FIELD to mapOf(
SOURCE_FIELD to condition.idOrCode,
LANG_FIELD to condition.lang
)
)
)
}

Expand All @@ -77,6 +83,8 @@ data class QueryLevelTrigger(
const val QUERY_LEVEL_TRIGGER_FIELD = "query_level_trigger"
const val CONDITION_FIELD = "condition"
const val SCRIPT_FIELD = "script"
const val SOURCE_FIELD = "source"
const val LANG_FIELD = "lang"

val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
Trigger::class.java,
Expand Down
19 changes: 19 additions & 0 deletions src/main/kotlin/org/opensearch/commons/alerting/model/Schedule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ sealed class Schedule : BaseModel {
abstract fun getPeriodEndingAt(endTime: Instant?): Pair<Instant, Instant>

abstract fun runningOnTime(lastExecutionTime: Instant?): Boolean

/** Returns a representation of the schedule suitable for passing into painless and mustache scripts. */
abstract fun asTemplateArg(): Map<String, Any>
}

/**
Expand Down Expand Up @@ -257,6 +260,14 @@ data class CronSchedule(
out.writeString(expression)
out.writeZoneId(timezone)
}

override fun asTemplateArg(): Map<String, Any> =
mapOf(
CRON_FIELD to mapOf(
EXPRESSION_FIELD to expression,
TIMEZONE_FIELD to timezone.toString()
)
)
}

data class IntervalSchedule(
Expand Down Expand Up @@ -354,4 +365,12 @@ data class IntervalSchedule(
out.writeInt(interval)
out.writeEnum(unit)
}

override fun asTemplateArg(): Map<String, Any> =
mapOf(
PERIOD_FIELD to mapOf(
INTERVAL_FIELD to interval,
UNIT_FIELD to unit.toString()
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ data class SearchInput(val indices: List<String>, val query: SearchSourceBuilder
return SearchInput(sin)
}
}

override fun asTemplateArg(): Map<String, Any> =
mapOf(
SEARCH_FIELD to mapOf(
INDICES_FIELD to indices,
QUERY_FIELD to query.toString()
)
)
}
Loading
Loading