Skip to content

Commit deebd8d

Browse files
Shares resource with users backend role by default upon config creation
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent 9da79ca commit deebd8d

18 files changed

+202
-55
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ configurations {
133133

134134
dependencies {
135135
implementation (group: 'org.opensearch', name:'opensearch-security-client', version: "${opensearch_build}")
136-
compileOnly "org.opensearch:opensearch-resource-sharing-spi:${opensearch_build}"
136+
compileOnly group: 'org.opensearch', name:'opensearch-resource-sharing-spi', version:"${opensearch_build}"
137137
implementation "org.opensearch:opensearch:${opensearch_version}"
138138
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${opensearch_version}"
139139
compileOnly "org.opensearch:opensearch-job-scheduler-spi:${job_scheduler_version}"

src/main/java/org/opensearch/ad/rest/handler/AbstractAnomalyDetectorActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
24+
import org.opensearch.Version;
2425
import org.opensearch.action.get.GetResponse;
2526
import org.opensearch.action.index.IndexResponse;
2627
import org.opensearch.action.support.WriteRequest;
@@ -54,6 +55,7 @@
5455
import org.opensearch.timeseries.util.SecurityClientUtil;
5556
import org.opensearch.transport.TransportService;
5657
import org.opensearch.transport.client.Client;
58+
import org.opensearch.transport.client.node.NodeClient;
5759

5860
import com.google.common.collect.Sets;
5961

@@ -151,7 +153,9 @@ public AbstractAnomalyDetectorActionHandler(
151153
String validationType,
152154
boolean isDryRun,
153155
Clock clock,
154-
Settings settings
156+
Settings settings,
157+
NodeClient nodeClient,
158+
Version nodeVersion
155159
) {
156160
super(
157161
anomalyDetector,
@@ -181,7 +185,9 @@ public AbstractAnomalyDetectorActionHandler(
181185
maxHCAnomalyDetectors,
182186
clock,
183187
settings,
184-
ValidationAspect.DETECTOR
188+
ValidationAspect.DETECTOR,
189+
nodeClient,
190+
nodeVersion
185191
);
186192

187193
}

src/main/java/org/opensearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package org.opensearch.ad.rest.handler;
1313

14+
import org.opensearch.Version;
1415
import org.opensearch.action.support.WriteRequest;
1516
import org.opensearch.ad.indices.ADIndexManagement;
1617
import org.opensearch.ad.model.AnomalyDetector;
@@ -26,6 +27,7 @@
2627
import org.opensearch.timeseries.util.SecurityClientUtil;
2728
import org.opensearch.transport.TransportService;
2829
import org.opensearch.transport.client.Client;
30+
import org.opensearch.transport.client.node.NodeClient;
2931

3032
/**
3133
* Anomaly detector REST action handler to process POST/PUT request.
@@ -80,7 +82,9 @@ public IndexAnomalyDetectorActionHandler(
8082
User user,
8183
ADTaskManager adTaskManager,
8284
SearchFeatureDao searchFeatureDao,
83-
Settings settings
85+
Settings settings,
86+
NodeClient nodeClient,
87+
Version nodeVersion
8488
) {
8589
super(
8690
clusterService,
@@ -106,7 +110,9 @@ public IndexAnomalyDetectorActionHandler(
106110
null,
107111
false,
108112
null,
109-
settings
113+
settings,
114+
nodeClient,
115+
nodeVersion
110116
);
111117
}
112118
}

src/main/java/org/opensearch/ad/rest/handler/ValidateAnomalyDetectorActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.time.Clock;
1515

16+
import org.opensearch.Version;
1617
import org.opensearch.ad.indices.ADIndexManagement;
1718
import org.opensearch.cluster.service.ClusterService;
1819
import org.opensearch.common.settings.Settings;
@@ -25,6 +26,7 @@
2526
import org.opensearch.timeseries.transport.ValidateConfigResponse;
2627
import org.opensearch.timeseries.util.SecurityClientUtil;
2728
import org.opensearch.transport.client.Client;
29+
import org.opensearch.transport.client.node.NodeClient;
2830

2931
/**
3032
* Anomaly detector REST action handler to process POST request.
@@ -70,7 +72,9 @@ public ValidateAnomalyDetectorActionHandler(
7072
SearchFeatureDao searchFeatureDao,
7173
String validationType,
7274
Clock clock,
73-
Settings settings
75+
Settings settings,
76+
NodeClient nodeClient,
77+
Version nodeVersion
7478
) {
7579
super(
7680
clusterService,
@@ -96,7 +100,9 @@ public ValidateAnomalyDetectorActionHandler(
96100
validationType,
97101
true,
98102
clock,
99-
settings
103+
settings,
104+
nodeClient,
105+
nodeVersion
100106
);
101107
}
102108
}

src/main/java/org/opensearch/ad/transport/IndexAnomalyDetectorTransportAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public class IndexAnomalyDetectorTransportAction extends HandledTransportAction<
6868
private final SearchFeatureDao searchFeatureDao;
6969
private final Settings settings;
7070
private final NodeClient nodeClient;
71-
private final Version nodeVersion;
7271

7372
@Inject
7473
public IndexAnomalyDetectorTransportAction(
@@ -97,7 +96,6 @@ public IndexAnomalyDetectorTransportAction(
9796
clusterService.getClusterSettings().addSettingsUpdateConsumer(AD_FILTER_BY_BACKEND_ROLES, it -> filterByEnabled = it);
9897
this.settings = settings;
9998
this.nodeClient = nodeClient;
100-
this.nodeVersion = transportService.getLocalNode().getVersion();
10199
}
102100

103101
@Override
@@ -242,7 +240,9 @@ protected void adExecute(
242240
detectorUser,
243241
adTaskManager,
244242
searchFeatureDao,
245-
settings
243+
settings,
244+
nodeClient,
245+
transportService.getLocalNode().getVersion()
246246
);
247247
indexAnomalyDetectorActionHandler.start(listener);
248248
}, listener);

src/main/java/org/opensearch/ad/transport/ValidateAnomalyDetectorTransportAction.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.opensearch.timeseries.util.SecurityClientUtil;
3636
import org.opensearch.transport.TransportService;
3737
import org.opensearch.transport.client.Client;
38+
import org.opensearch.transport.client.node.NodeClient;
3839

3940
public class ValidateAnomalyDetectorTransportAction extends BaseValidateConfigTransportAction<ADIndex, ADIndexManagement> {
4041
public static final Logger logger = LogManager.getLogger(ValidateAnomalyDetectorTransportAction.class);
@@ -49,7 +50,8 @@ public ValidateAnomalyDetectorTransportAction(
4950
ADIndexManagement anomalyDetectionIndices,
5051
ActionFilters actionFilters,
5152
TransportService transportService,
52-
SearchFeatureDao searchFeatureDao
53+
SearchFeatureDao searchFeatureDao,
54+
NodeClient nodeClient
5355
) {
5456
super(
5557
ValidateAnomalyDetectorAction.NAME,
@@ -63,7 +65,8 @@ public ValidateAnomalyDetectorTransportAction(
6365
transportService,
6466
searchFeatureDao,
6567
AD_FILTER_BY_BACKEND_ROLES,
66-
ValidationAspect.DETECTOR
68+
ValidationAspect.DETECTOR,
69+
nodeClient
6770
);
6871
}
6972

@@ -86,7 +89,9 @@ protected Processor<ValidateConfigResponse> createProcessor(Config detector, Val
8689
searchFeatureDao,
8790
request.getValidationType(),
8891
clock,
89-
settings
92+
settings,
93+
nodeClient,
94+
clusterService.localNode().getVersion()
9095
);
9196
}
9297
}

src/main/java/org/opensearch/forecast/rest/handler/AbstractForecasterActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.logging.log4j.LogManager;
2121
import org.apache.logging.log4j.Logger;
22+
import org.opensearch.Version;
2223
import org.opensearch.action.get.GetResponse;
2324
import org.opensearch.action.index.IndexResponse;
2425
import org.opensearch.action.support.WriteRequest;
@@ -52,6 +53,7 @@
5253
import org.opensearch.timeseries.util.SecurityClientUtil;
5354
import org.opensearch.transport.TransportService;
5455
import org.opensearch.transport.client.Client;
56+
import org.opensearch.transport.client.node.NodeClient;
5557

5658
import com.google.common.collect.Sets;
5759

@@ -166,7 +168,9 @@ public AbstractForecasterActionHandler(
166168
String validationType,
167169
boolean isDryRun,
168170
Clock clock,
169-
Settings settings
171+
Settings settings,
172+
NodeClient nodeClient,
173+
Version nodeVersion
170174
) {
171175
super(
172176
forecaster,
@@ -196,7 +200,9 @@ public AbstractForecasterActionHandler(
196200
maxHCForecasters,
197201
clock,
198202
settings,
199-
ValidationAspect.FORECASTER
203+
ValidationAspect.FORECASTER,
204+
nodeClient,
205+
nodeVersion
200206
);
201207
}
202208

src/main/java/org/opensearch/forecast/rest/handler/IndexForecasterActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package org.opensearch.forecast.rest.handler;
1313

14+
import org.opensearch.Version;
1415
import org.opensearch.action.support.WriteRequest;
1516
import org.opensearch.cluster.service.ClusterService;
1617
import org.opensearch.common.settings.Settings;
@@ -26,6 +27,7 @@
2627
import org.opensearch.timeseries.util.SecurityClientUtil;
2728
import org.opensearch.transport.TransportService;
2829
import org.opensearch.transport.client.Client;
30+
import org.opensearch.transport.client.node.NodeClient;
2931

3032
/**
3133
* process create/update forecaster request
@@ -74,7 +76,9 @@ public IndexForecasterActionHandler(
7476
User user,
7577
ForecastTaskManager taskManager,
7678
SearchFeatureDao searchFeatureDao,
77-
Settings settings
79+
Settings settings,
80+
NodeClient nodeClient,
81+
Version nodeVersion
7882
) {
7983
super(
8084
clusterService,
@@ -100,7 +104,9 @@ public IndexForecasterActionHandler(
100104
null,
101105
false,
102106
null,
103-
settings
107+
settings,
108+
nodeClient,
109+
nodeVersion
104110
);
105111
}
106112
}

src/main/java/org/opensearch/forecast/rest/handler/ValidateForecasterActionHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import java.time.Clock;
99

10+
import org.opensearch.Version;
1011
import org.opensearch.cluster.service.ClusterService;
1112
import org.opensearch.common.settings.Settings;
1213
import org.opensearch.common.unit.TimeValue;
@@ -19,6 +20,7 @@
1920
import org.opensearch.timeseries.transport.ValidateConfigResponse;
2021
import org.opensearch.timeseries.util.SecurityClientUtil;
2122
import org.opensearch.transport.client.Client;
23+
import org.opensearch.transport.client.node.NodeClient;
2224

2325
/**
2426
* ValidateForecasterActionHandler extends the AbstractForecasterActionHandler to specifically handle
@@ -68,7 +70,9 @@ public ValidateForecasterActionHandler(
6870
SearchFeatureDao searchFeatureDao,
6971
String validationType,
7072
Clock clock,
71-
Settings settings
73+
Settings settings,
74+
NodeClient nodeClient,
75+
Version nodeVersion
7276
) {
7377
super(
7478
clusterService,
@@ -94,7 +98,9 @@ public ValidateForecasterActionHandler(
9498
validationType,
9599
true,
96100
clock,
97-
settings
101+
settings,
102+
nodeClient,
103+
nodeVersion
98104
);
99105
}
100106

src/main/java/org/opensearch/forecast/transport/IndexForecasterTransportAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ protected void forecastExecute(
223223
forecastUser,
224224
taskManager,
225225
searchFeatureDao,
226-
settings
226+
settings,
227+
nodeClient,
228+
transportService.getLocalNode().getVersion()
227229
);
228230
indexForecasterActionHandler.start(listener);
229231
}, listener);

0 commit comments

Comments
 (0)