Skip to content

Commit

Permalink
Moving the ODFE Settings to Legacy Settings and adding the new settin…
Browse files Browse the repository at this point in the history
…gs compatible with Opensearch (opensearch-project#18)

Adding Settings Backward Compatibility. 

Signed-off-by: Aditya Jindal <[email protected]>
  • Loading branch information
adityaj1107 authored May 24, 2021
1 parent 25efd5b commit 014ecc9
Show file tree
Hide file tree
Showing 15 changed files with 612 additions and 72 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ jobs:
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0.0-beta1'
ref: '1.x'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=beta1 -Dbuild.snapshot=false
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=rc1 -Dbuild.snapshot=false
# This step adds dependency, common-utils
- name: Checkout common-utils
uses: actions/checkout@v2
with:
repository: 'opensearch-project/common-utils'
path: common-utils
ref: 'main'
- name: Build common-utils
working-directory: ./common-utils
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-beta1
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-rc1
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout Branch
uses: actions/checkout@v2
Expand All @@ -51,4 +52,4 @@ jobs:
with:
java-version: 14
- name: Run integration tests with multi node config
run: ./gradlew integTest -PnumNodes=3 -Dopensearch.version=1.0.0-beta1
run: ./gradlew integTest -PnumNodes=3 -Dopensearch.version=1.0.0-rc1
10 changes: 5 additions & 5 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0.0-beta1'
ref: '1.x'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=beta1 -Dbuild.snapshot=false
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=rc1 -Dbuild.snapshot=false

# dependencies: common-utils
- name: Checkout common-utils
Expand All @@ -48,10 +48,10 @@ jobs:
path: common-utils
- name: Build common-utils
working-directory: ./common-utils
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-beta1
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-rc1

- name: Build and run with Gradle
run: ./gradlew build -Dopensearch.version=1.0.0-beta1
run: ./gradlew build -Dopensearch.version=1.0.0-rc1

# - name: Create Artifact Path
# run: |
Expand All @@ -70,4 +70,4 @@ jobs:
# path: alerting-artifacts
# Publish to local maven
- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-beta1
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0-rc1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import org.opensearch.alerting.core.model.ScheduledJob
import org.opensearch.alerting.core.model.SearchInput
import org.opensearch.alerting.core.resthandler.RestScheduledJobStatsHandler
import org.opensearch.alerting.core.schedule.JobScheduler
import org.opensearch.alerting.core.settings.LegacyOpenDistroScheduledJobSettings
import org.opensearch.alerting.core.settings.ScheduledJobSettings
import org.opensearch.alerting.model.Monitor
import org.opensearch.alerting.resthandler.RestAcknowledgeAlertAction
Expand All @@ -77,6 +78,8 @@ import org.opensearch.alerting.resthandler.RestSearchMonitorAction
import org.opensearch.alerting.script.TriggerScript
import org.opensearch.alerting.settings.AlertingSettings
import org.opensearch.alerting.settings.DestinationSettings
import org.opensearch.alerting.settings.LegacyOpenDistroAlertingSettings
import org.opensearch.alerting.settings.LegacyOpenDistroDestinationSettings
import org.opensearch.alerting.transport.TransportAcknowledgeAlertAction
import org.opensearch.alerting.transport.TransportDeleteDestinationAction
import org.opensearch.alerting.transport.TransportDeleteEmailAccountAction
Expand Down Expand Up @@ -253,6 +256,12 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
ScheduledJobSettings.SWEEP_PERIOD,
ScheduledJobSettings.SWEEP_PAGE_SIZE,
ScheduledJobSettings.SWEEPER_ENABLED,
LegacyOpenDistroScheduledJobSettings.REQUEST_TIMEOUT,
LegacyOpenDistroScheduledJobSettings.SWEEP_BACKOFF_MILLIS,
LegacyOpenDistroScheduledJobSettings.SWEEP_BACKOFF_RETRY_COUNT,
LegacyOpenDistroScheduledJobSettings.SWEEP_PERIOD,
LegacyOpenDistroScheduledJobSettings.SWEEP_PAGE_SIZE,
LegacyOpenDistroScheduledJobSettings.SWEEPER_ENABLED,
AlertingSettings.INPUT_TIMEOUT,
AlertingSettings.INDEX_TIMEOUT,
AlertingSettings.BULK_TIMEOUT,
Expand All @@ -269,10 +278,30 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
AlertingSettings.REQUEST_TIMEOUT,
AlertingSettings.MAX_ACTION_THROTTLE_VALUE,
AlertingSettings.FILTER_BY_BACKEND_ROLES,
LegacyOpenDistroAlertingSettings.INPUT_TIMEOUT,
LegacyOpenDistroAlertingSettings.INDEX_TIMEOUT,
LegacyOpenDistroAlertingSettings.BULK_TIMEOUT,
LegacyOpenDistroAlertingSettings.ALERT_BACKOFF_MILLIS,
LegacyOpenDistroAlertingSettings.ALERT_BACKOFF_COUNT,
LegacyOpenDistroAlertingSettings.MOVE_ALERTS_BACKOFF_MILLIS,
LegacyOpenDistroAlertingSettings.MOVE_ALERTS_BACKOFF_COUNT,
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_ENABLED,
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_ROLLOVER_PERIOD,
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_INDEX_MAX_AGE,
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_MAX_DOCS,
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_RETENTION_PERIOD,
LegacyOpenDistroAlertingSettings.ALERTING_MAX_MONITORS,
LegacyOpenDistroAlertingSettings.REQUEST_TIMEOUT,
LegacyOpenDistroAlertingSettings.MAX_ACTION_THROTTLE_VALUE,
LegacyOpenDistroAlertingSettings.FILTER_BY_BACKEND_ROLES,
DestinationSettings.EMAIL_USERNAME,
DestinationSettings.EMAIL_PASSWORD,
DestinationSettings.ALLOW_LIST,
DestinationSettings.HOST_DENY_LIST
DestinationSettings.HOST_DENY_LIST,
LegacyOpenDistroDestinationSettings.EMAIL_USERNAME,
LegacyOpenDistroDestinationSettings.EMAIL_PASSWORD,
LegacyOpenDistroDestinationSettings.ALLOW_LIST,
LegacyOpenDistroDestinationSettings.HOST_DENY_LIST
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ package org.opensearch.alerting.settings

import org.opensearch.alerting.AlertingPlugin
import org.opensearch.common.settings.Setting
import org.opensearch.common.unit.TimeValue
import java.util.concurrent.TimeUnit

/**
* settings specific to [AlertingPlugin]. These settings include things like history index max age, request timeout, etc...
Expand All @@ -42,99 +40,98 @@ class AlertingSettings {
const val MONITOR_MAX_TRIGGERS = 10

val ALERTING_MAX_MONITORS = Setting.intSetting(
"opendistro.alerting.monitor.max_monitors",
1000,
"plugins.alerting.monitor.max_monitors",
LegacyOpenDistroAlertingSettings.ALERTING_MAX_MONITORS,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val INPUT_TIMEOUT = Setting.positiveTimeSetting(
"opendistro.alerting.input_timeout",
TimeValue.timeValueSeconds(30),
"plugins.alerting.input_timeout",
LegacyOpenDistroAlertingSettings.INPUT_TIMEOUT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val INDEX_TIMEOUT = Setting.positiveTimeSetting(
"opendistro.alerting.index_timeout",
TimeValue.timeValueSeconds(60),
"plugins.alerting.index_timeout",
LegacyOpenDistroAlertingSettings.INDEX_TIMEOUT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val BULK_TIMEOUT = Setting.positiveTimeSetting(
"opendistro.alerting.bulk_timeout",
TimeValue.timeValueSeconds(120),
"plugins.alerting.bulk_timeout",
LegacyOpenDistroAlertingSettings.BULK_TIMEOUT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_BACKOFF_MILLIS = Setting.positiveTimeSetting(
"opendistro.alerting.alert_backoff_millis",
TimeValue.timeValueMillis(50),
"plugins.alerting.alert_backoff_millis",
LegacyOpenDistroAlertingSettings.ALERT_BACKOFF_MILLIS,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_BACKOFF_COUNT = Setting.intSetting(
"opendistro.alerting.alert_backoff_count",
2,
"plugins.alerting.alert_backoff_count",
LegacyOpenDistroAlertingSettings.ALERT_BACKOFF_COUNT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val MOVE_ALERTS_BACKOFF_MILLIS = Setting.positiveTimeSetting(
"opendistro.alerting.move_alerts_backoff_millis",
TimeValue.timeValueMillis(250),
"plugins.alerting.move_alerts_backoff_millis",
LegacyOpenDistroAlertingSettings.MOVE_ALERTS_BACKOFF_MILLIS,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val MOVE_ALERTS_BACKOFF_COUNT = Setting.intSetting(
"opendistro.alerting.move_alerts_backoff_count",
3,
"plugins.alerting.move_alerts_backoff_count",
LegacyOpenDistroAlertingSettings.MOVE_ALERTS_BACKOFF_COUNT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_HISTORY_ENABLED = Setting.boolSetting(
"opendistro.alerting.alert_history_enabled",
true,
"plugins.alerting.alert_history_enabled",
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_ENABLED,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_HISTORY_ROLLOVER_PERIOD = Setting.positiveTimeSetting(
"opendistro.alerting.alert_history_rollover_period",
TimeValue.timeValueHours(12),
"plugins.alerting.alert_history_rollover_period",
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_ROLLOVER_PERIOD,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_HISTORY_INDEX_MAX_AGE = Setting.positiveTimeSetting(
"opendistro.alerting.alert_history_max_age",
TimeValue(30, TimeUnit.DAYS),
"plugins.alerting.alert_history_max_age",
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_INDEX_MAX_AGE,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_HISTORY_MAX_DOCS = Setting.longSetting(
"opendistro.alerting.alert_history_max_docs",
1000L,
0L,
"plugins.alerting.alert_history_max_docs",
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_MAX_DOCS,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val ALERT_HISTORY_RETENTION_PERIOD = Setting.positiveTimeSetting(
"opendistro.alerting.alert_history_retention_period",
TimeValue(60, TimeUnit.DAYS),
"plugins.alerting.alert_history_retention_period",
LegacyOpenDistroAlertingSettings.ALERT_HISTORY_RETENTION_PERIOD,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val REQUEST_TIMEOUT = Setting.positiveTimeSetting(
"opendistro.alerting.request_timeout",
TimeValue.timeValueSeconds(10),
"plugins.alerting.request_timeout",
LegacyOpenDistroAlertingSettings.REQUEST_TIMEOUT,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val MAX_ACTION_THROTTLE_VALUE = Setting.positiveTimeSetting(
"opendistro.alerting.action_throttle_max_value",
TimeValue.timeValueHours(24),
"plugins.alerting.action_throttle_max_value",
LegacyOpenDistroAlertingSettings.MAX_ACTION_THROTTLE_VALUE,
Setting.Property.NodeScope, Setting.Property.Dynamic
)

val FILTER_BY_BACKEND_ROLES = Setting.boolSetting(
"opendistro.alerting.filter_by_backend_roles",
false,
"plugins.alerting.filter_by_backend_roles",
LegacyOpenDistroAlertingSettings.FILTER_BY_BACKEND_ROLES,
Setting.Property.NodeScope, Setting.Property.Dynamic
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

package org.opensearch.alerting.settings

import org.opensearch.alerting.util.DestinationType
import org.opensearch.common.settings.SecureSetting
import org.opensearch.common.settings.SecureString
import org.opensearch.common.settings.Setting
Expand All @@ -38,17 +37,14 @@ import java.util.function.Function
* types require SecureSettings and need additional logic for retrieving and loading them.
*/
class DestinationSettings {

companion object {

const val DESTINATION_SETTING_PREFIX = "opendistro.alerting.destination."
const val DESTINATION_SETTING_PREFIX = "plugins.alerting.destination."
const val EMAIL_DESTINATION_SETTING_PREFIX = DESTINATION_SETTING_PREFIX + "email."
val ALLOW_LIST_ALL = DestinationType.values().toList().map { it.value }
val ALLOW_LIST_NONE = emptyList<String>()

val ALLOW_LIST: Setting<List<String>> = Setting.listSetting(
DESTINATION_SETTING_PREFIX + "allow_list",
ALLOW_LIST_ALL,
LegacyOpenDistroDestinationSettings.ALLOW_LIST,
Function.identity(),
Setting.Property.NodeScope,
Setting.Property.Dynamic
Expand All @@ -58,19 +54,19 @@ class DestinationSettings {
EMAIL_DESTINATION_SETTING_PREFIX,
"username",
// Needed to coerce lambda to Function type for some reason to avoid argument mismatch compile error
Function { key: String -> SecureSetting.secureString(key, null) }
Function { key: String -> SecureSetting.secureString(key, LegacyOpenDistroDestinationSettings.EMAIL_USERNAME) }
)

val EMAIL_PASSWORD: Setting.AffixSetting<SecureString> = Setting.affixKeySetting(
EMAIL_DESTINATION_SETTING_PREFIX,
"password",
// Needed to coerce lambda to Function type for some reason to avoid argument mismatch compile error
Function { key: String -> SecureSetting.secureString(key, null) }
Function { key: String -> SecureSetting.secureString(key, LegacyOpenDistroDestinationSettings.EMAIL_PASSWORD) }
)

val HOST_DENY_LIST: Setting<List<String>> = Setting.listSetting(
"opendistro.destination.host.deny_list",
emptyList<String>(),
"plugins.destination.host.deny_list",
LegacyOpenDistroDestinationSettings.HOST_DENY_LIST,
Function.identity(),
Setting.Property.NodeScope,
Setting.Property.Final
Expand Down
Loading

0 comments on commit 014ecc9

Please sign in to comment.