From 912bd805fef7fa851b499b084270dae410d46353 Mon Sep 17 00:00:00 2001 From: Dennis Toepker Date: Thu, 30 Apr 2026 22:10:13 -0700 Subject: [PATCH] temporarily putting PPL Alerting serde behind 3.6 check Signed-off-by: Dennis Toepker --- .../org/opensearch/commons/alerting/model/Alert.kt | 9 ++++++--- .../commons/alerting/model/MonitorRunResult.kt | 12 ++++++++---- .../alerting/model/QueryLevelTriggerRunResult.kt | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/opensearch/commons/alerting/model/Alert.kt b/src/main/kotlin/org/opensearch/commons/alerting/model/Alert.kt index f0fa69c9..ce2d322d 100644 --- a/src/main/kotlin/org/opensearch/commons/alerting/model/Alert.kt +++ b/src/main/kotlin/org/opensearch/commons/alerting/model/Alert.kt @@ -417,12 +417,14 @@ data class Alert( executionId = sin.readOptionalString(), associatedAlertIds = sin.readStringList(), clusters = sin.readOptionalStringList(), - query = if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + query = if (sin.version.onOrAfter(Version.V_3_6_0)) { sin.readOptionalString() } else { null }, - queryResults = if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + queryResults = if (sin.version.onOrAfter(Version.V_3_6_0)) { sin.readList { input -> suppressWarning(input.readMap()) } } else { listOf() @@ -470,7 +472,8 @@ data class Alert( out.writeOptionalString(executionId) out.writeStringCollection(associatedAlertIds) out.writeOptionalStringArray(clusters?.toTypedArray()) - if (out.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + if (out.version.onOrAfter(Version.V_3_6_0)) { out.writeOptionalString(query) out.writeCollection(queryResults) { output, map -> output.writeMap(map) diff --git a/src/main/kotlin/org/opensearch/commons/alerting/model/MonitorRunResult.kt b/src/main/kotlin/org/opensearch/commons/alerting/model/MonitorRunResult.kt index c8125394..5b8d70fc 100644 --- a/src/main/kotlin/org/opensearch/commons/alerting/model/MonitorRunResult.kt +++ b/src/main/kotlin/org/opensearch/commons/alerting/model/MonitorRunResult.kt @@ -129,7 +129,8 @@ data class InputRunResults( out.writeMap(map) } - if (out.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + if (out.version.onOrAfter(Version.V_3_6_0)) { out.writeVInt(pplBaseQueryResults.size) for (datarow in pplBaseQueryResults) { out.writeMap(datarow) @@ -149,18 +150,21 @@ data class InputRunResults( for (i in 0 until count) { list.add(suppressWarning(sin.readMap())) // result(map) } - val pplCount = if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + val pplCount = if (sin.version.onOrAfter(Version.V_3_6_0)) { sin.readVInt() } else { 0 } val pplList = mutableListOf>() - if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + if (sin.version.onOrAfter(Version.V_3_6_0)) { for (i in 0 until pplCount) { pplList.add(suppressWarning(sin.readMap())) // pplResults } } - val pplNumResults = if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + val pplNumResults = if (sin.version.onOrAfter(Version.V_3_6_0)) { sin.readOptionalLong() } else { null diff --git a/src/main/kotlin/org/opensearch/commons/alerting/model/QueryLevelTriggerRunResult.kt b/src/main/kotlin/org/opensearch/commons/alerting/model/QueryLevelTriggerRunResult.kt index 04e77564..98bd3c62 100644 --- a/src/main/kotlin/org/opensearch/commons/alerting/model/QueryLevelTriggerRunResult.kt +++ b/src/main/kotlin/org/opensearch/commons/alerting/model/QueryLevelTriggerRunResult.kt @@ -30,7 +30,8 @@ open class QueryLevelTriggerRunResult( error = sin.readException(), triggered = sin.readBoolean(), actionResults = sin.readMap() as MutableMap, - pplCustomQueryResults = if (sin.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + pplCustomQueryResults = if (sin.version.onOrAfter(Version.V_3_6_0)) { sin.readList { it.readMap() } } else { listOf() @@ -62,7 +63,8 @@ open class QueryLevelTriggerRunResult( super.writeTo(out) out.writeBoolean(triggered) out.writeMap(actionResults as Map) - if (out.version.onOrAfter(Version.V_3_7_0)) { + // TODO: change to 3.7 when alerting version bump happens + if (out.version.onOrAfter(Version.V_3_6_0)) { out.writeCollection(pplCustomQueryResults) { stream, map -> stream.writeMap(map) } } }