Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix for upgrading mapping #309

Merged
merged 2 commits into from
Nov 10, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ protected void runAdJob(
);
return;
}
indexUtil.updateMappingIfNecessary();
/*
* We need to handle 3 cases:
* 1. Detectors created by older versions and never updated. These detectors wont have User details in the
Expand All @@ -233,7 +234,7 @@ protected void runAdJob(
try (InjectSecurity injectSecurity = new InjectSecurity(detectorId, settings, client.threadPool().getThreadContext())) {
// Injecting user role to verify if the user has permissions for our API.
injectSecurity.inject(user, roles);
indexUtil.updateMappingIfNecessary();

AnomalyResultRequest request = new AnomalyResultRequest(
detectorId,
detectionStartTime.toEpochMilli(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,11 @@ public void updateMappingIfNecessary() {
}

final GroupedActionListener<Void> conglomerateListeneer = new GroupedActionListener<>(
ActionListener.wrap(r -> updateRunning.set(false), exception -> logger.error("Fail to updatea all mappings")),
ActionListener.wrap(r -> updateRunning.set(false), exception -> {
// TODO: don't retry endlessly. Can be annoying if there are too many exception logs.
updateRunning.set(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If remove this line, will not update index mapping if any exception happens?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if removing this line, we will only try to update mapping once per node.

logger.error("Fail to update AD indices' mappings");
}),
updates.size()
);

Expand All @@ -602,7 +606,14 @@ public void updateMappingIfNecessary() {
}
conglomerateListeneer.onResponse(null);
}, exception -> {
logger.error(new ParameterizedMessage("Fail to update [{}]'s mapping", adIndex.getIndexName()), exception);
logger
.error(
new ParameterizedMessage(
"Fail to update [{}]'s mapping due to [{}]",
adIndex.getIndexName(),
exception.getMessage()
)
);
conglomerateListeneer.onFailure(exception);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,27 @@ public final class AnomalyDetectorSettings {
private AnomalyDetectorSettings() {}

public static final Setting<Integer> MAX_SINGLE_ENTITY_ANOMALY_DETECTORS = Setting
.intSetting("opendistro.anomaly_detection.max_anomaly_detectors", 1000, Setting.Property.NodeScope, Setting.Property.Dynamic);
.intSetting(
"opendistro.anomaly_detection.max_anomaly_detectors",
1000,
0,
10_000,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);

public static final Setting<Integer> MAX_MULTI_ENTITY_ANOMALY_DETECTORS = Setting
.intSetting(
"opendistro.anomaly_detection.max_multi_entity_anomaly_detectors",
10,
0,
10_000,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);

public static final Setting<Integer> MAX_ANOMALY_FEATURES = Setting
.intSetting("opendistro.anomaly_detection.max_anomaly_features", 5, Setting.Property.NodeScope, Setting.Property.Dynamic);
.intSetting("opendistro.anomaly_detection.max_anomaly_features", 5, 0, 100, Setting.Property.NodeScope, Setting.Property.Dynamic);

public static final Setting<TimeValue> REQUEST_TIMEOUT = Setting
.positiveTimeSetting(
Expand Down Expand Up @@ -251,7 +260,14 @@ private AnomalyDetectorSettings() {}

// Increase the value will adding pressure to indexing anomaly results and our feature query
public static final Setting<Integer> MAX_ENTITIES_PER_QUERY = Setting
.intSetting("opendistro.anomaly_detection.max_entities_per_query", 1000, 1, Setting.Property.NodeScope, Setting.Property.Dynamic);
.intSetting(
"opendistro.anomaly_detection.max_entities_per_query",
1000,
1,
100_000_000,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);

// Default number of entities retrieved for Preview API
public static final int DEFAULT_ENTITIES_FOR_PREVIEW = 30;
Expand All @@ -262,6 +278,7 @@ private AnomalyDetectorSettings() {}
"opendistro.anomaly_detection.max_entities_for_preview",
DEFAULT_ENTITIES_FOR_PREVIEW,
1,
1000,
Setting.Property.NodeScope,
Setting.Property.Dynamic
);
Expand All @@ -278,7 +295,7 @@ private AnomalyDetectorSettings() {}

// max number of primary shards of an AD index
public static final Setting<Integer> MAX_PRIMARY_SHARDS = Setting
.intSetting("opendistro.anomaly_detection.max_primary_shards", 10, 0, Setting.Property.NodeScope, Setting.Property.Dynamic);
.intSetting("opendistro.anomaly_detection.max_primary_shards", 10, 0, 200, Setting.Property.NodeScope, Setting.Property.Dynamic);

// max entity value's length
public static int MAX_ENTITY_LENGTH = 256;
Expand Down