mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Remove trappy timeouts from IndicesAliasesRequest
(#123987)
Relates #107984
This commit is contained in:
parent
404c9e6290
commit
77a3d30d26
76 changed files with 760 additions and 338 deletions
|
@ -17,6 +17,7 @@ import org.elasticsearch.common.settings.IndexScopedSettings;
|
|||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.core.TimeValue;
|
||||
import org.elasticsearch.features.NodeFeature;
|
||||
import org.elasticsearch.indices.SystemIndexDescriptor;
|
||||
import org.elasticsearch.license.License;
|
||||
|
@ -251,6 +252,14 @@ public class EnterpriseSearch extends Plugin implements ActionPlugin, SystemInde
|
|||
License.OperationMode.ENTERPRISE
|
||||
);
|
||||
|
||||
/**
|
||||
* Hard-coded timeout used for {@link org.elasticsearch.action.support.master.MasterNodeRequest#masterNodeTimeout()} for requests to
|
||||
* the master node from Enterprise Search code. Wherever possible, prefer to use a user-controlled timeout instead of this.
|
||||
*
|
||||
* @see <a href="https://github.com/elastic/elasticsearch/issues/107984">#107984</a>
|
||||
*/
|
||||
public static final TimeValue HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT = TimeValue.THIRTY_SECONDS;
|
||||
|
||||
@Override
|
||||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
|
||||
var usageAction = new ActionHandler<>(XPackUsageFeatureAction.ENTERPRISE_SEARCH, EnterpriseSearchUsageTransportAction.class);
|
||||
|
|
|
@ -80,6 +80,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
|
||||
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.xpack.application.EnterpriseSearch.HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT;
|
||||
import static org.elasticsearch.xpack.core.ClientHelper.ENT_SEARCH_ORIGIN;
|
||||
|
||||
/**
|
||||
|
@ -260,7 +261,10 @@ public class SearchApplicationIndexService {
|
|||
requestBuilder = updateAliasIndices(currentAliases, targetAliases, searchAliasName);
|
||||
|
||||
} else {
|
||||
requestBuilder = client.admin().indices().prepareAliases().addAlias(app.indices(), searchAliasName);
|
||||
requestBuilder = client.admin()
|
||||
.indices()
|
||||
.prepareAliases(HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT, HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT)
|
||||
.addAlias(app.indices(), searchAliasName);
|
||||
}
|
||||
|
||||
requestBuilder.execute(listener);
|
||||
|
@ -271,7 +275,9 @@ public class SearchApplicationIndexService {
|
|||
Set<String> deleteIndices = new HashSet<>(currentAliases);
|
||||
deleteIndices.removeAll(targetAliases);
|
||||
|
||||
IndicesAliasesRequestBuilder aliasesRequestBuilder = client.admin().indices().prepareAliases();
|
||||
IndicesAliasesRequestBuilder aliasesRequestBuilder = client.admin()
|
||||
.indices()
|
||||
.prepareAliases(HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT, HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT);
|
||||
|
||||
// Always re-add aliases, as an index could have been removed manually and it must be restored
|
||||
for (String newIndex : targetAliases) {
|
||||
|
@ -330,9 +336,10 @@ public class SearchApplicationIndexService {
|
|||
}
|
||||
|
||||
private void removeAlias(String searchAliasName, ActionListener<AcknowledgedResponse> listener) {
|
||||
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest().addAliasAction(
|
||||
IndicesAliasesRequest.AliasActions.remove().aliases(searchAliasName).indices("*")
|
||||
);
|
||||
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest(
|
||||
HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT,
|
||||
HARD_CODED_ENTERPRISE_SEARCH_MASTER_NODE_TIMEOUT
|
||||
).addAliasAction(IndicesAliasesRequest.AliasActions.remove().aliases(searchAliasName).indices("*"));
|
||||
client.admin().indices().aliases(aliasesRequest, new ActionListener<>() {
|
||||
@Override
|
||||
public void onResponse(IndicesAliasesResponse response) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue