Skip to content

Commit a243ea3

Browse files
committed
Refactor: Replace selector-based routing with unified policy system
- Replace previous Selector extensions with Policy-based routing system - Add Router interface with Route() method for request-aware connection selection - Add configurable resurrection timeout settings (ResurrectTimeoutInitial, ResurrectTimeoutFactorCutoff) - Add connection pool promotion/demotion with state preservation - Implement health checking with exponential backoff retry logic - Remove 6 selector_*.go files and add 8 policy_*.go files for cleaner architecture - Add multi-node cluster testing infrastructure with dedicated cluster manager support Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent c2f3f5b commit a243ea3

63 files changed

Lines changed: 6479 additions & 3357 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci/opensearch/Dockerfile.opensearch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ RUN if [ "$SECURE_INTEGRATION" != "true" ] ; then \
4141
fi \
4242
fi
4343

44+
# Ensure the repository mount point has correct permissions for snapshots
45+
RUN mkdir -p /usr/share/opensearch/mnt && chown opensearch:opensearch /usr/share/opensearch/mnt
46+
4447
HEALTHCHECK --start-period=20s --interval=30s \
4548
CMD curl -sf --retry 5 --max-time 5 --retry-delay 5 --retry-max-time 30 --retry-all-errors \
4649
$(if $SECURE_INTEGRATION; then echo "--cert config/kirk.pem --key config/kirk-key.pem -k https://"; fi)"localhost:9200" \

.ci/opensearch/docker-compose.yml

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
opensearch:
2+
opensearch-node1:
33
deploy:
44
restart_policy:
55
condition: any
@@ -11,11 +11,132 @@ services:
1111
- OPENSEARCH_VERSION=${OPENSEARCH_VERSION:-latest}
1212
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
1313
environment:
14-
- discovery.type=single-node
15-
- bootstrap.memory_lock=true
14+
- cluster.name=opensearch-cluster
15+
- node.name=opensearch-node1
16+
- node.roles=cluster_manager,data,ingest
17+
- discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
18+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
19+
- bootstrap.memory_lock=false # Disable memory locking for development
1620
- path.repo=/usr/share/opensearch/mnt
1721
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
1822
- plugins.index_state_management.job_interval=1
23+
# Network settings for proper node discovery
24+
- network.host=0.0.0.0
25+
- transport.host=0.0.0.0
26+
- http.host=0.0.0.0
27+
# Publish HTTP address for external clients only
28+
- http.publish_host=localhost
29+
- http.publish_port=9200
30+
# Memory settings
31+
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
1932
ports:
2033
- "9200:9200"
34+
- "9300:9300"
35+
networks:
36+
- opensearch-net
37+
volumes:
38+
- opensearch-data1:/usr/share/opensearch/data
39+
- opensearch-snapshots:/usr/share/opensearch/mnt
2140
user: opensearch
41+
ulimits:
42+
memlock:
43+
soft: -1
44+
hard: -1
45+
46+
opensearch-node2:
47+
deploy:
48+
restart_policy:
49+
condition: any
50+
build:
51+
context: .
52+
dockerfile: Dockerfile.opensearch
53+
args:
54+
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
55+
- OPENSEARCH_VERSION=${OPENSEARCH_VERSION:-latest}
56+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
57+
environment:
58+
- cluster.name=opensearch-cluster
59+
- node.name=opensearch-node2
60+
- node.roles=cluster_manager,data,ingest
61+
- discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
62+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
63+
- bootstrap.memory_lock=false # Disable memory locking for development
64+
- path.repo=/usr/share/opensearch/mnt
65+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
66+
- plugins.index_state_management.job_interval=1
67+
# Network settings for proper node discovery
68+
- network.host=0.0.0.0
69+
- transport.host=0.0.0.0
70+
- http.host=0.0.0.0
71+
# Publish HTTP address for external clients only
72+
- http.publish_host=localhost
73+
- http.publish_port=9201
74+
# Memory settings
75+
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
76+
ports:
77+
- "9201:9200"
78+
- "9301:9300"
79+
networks:
80+
- opensearch-net
81+
volumes:
82+
- opensearch-data2:/usr/share/opensearch/data
83+
- opensearch-snapshots:/usr/share/opensearch/mnt
84+
user: opensearch
85+
ulimits:
86+
memlock:
87+
soft: -1
88+
hard: -1
89+
90+
opensearch-node3:
91+
deploy:
92+
restart_policy:
93+
condition: any
94+
build:
95+
context: .
96+
dockerfile: Dockerfile.opensearch
97+
args:
98+
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
99+
- OPENSEARCH_VERSION=${OPENSEARCH_VERSION:-latest}
100+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
101+
environment:
102+
- cluster.name=opensearch-cluster
103+
- node.name=opensearch-node3
104+
- node.roles=cluster_manager,data,ingest
105+
- discovery.seed_hosts=opensearch-node1,opensearch-node2,opensearch-node3
106+
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2,opensearch-node3
107+
- bootstrap.memory_lock=false # Disable memory locking for development
108+
- path.repo=/usr/share/opensearch/mnt
109+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
110+
- plugins.index_state_management.job_interval=1
111+
# Network settings for proper node discovery
112+
- network.host=0.0.0.0
113+
- transport.host=0.0.0.0
114+
- http.host=0.0.0.0
115+
# Publish HTTP address for external clients only
116+
- http.publish_host=localhost
117+
- http.publish_port=9202
118+
# Memory settings
119+
- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
120+
ports:
121+
- "9202:9200"
122+
- "9302:9300"
123+
networks:
124+
- opensearch-net
125+
volumes:
126+
- opensearch-data3:/usr/share/opensearch/data
127+
- opensearch-snapshots:/usr/share/opensearch/mnt
128+
user: opensearch
129+
ulimits:
130+
memlock:
131+
soft: -1
132+
hard: -1
133+
134+
networks:
135+
opensearch-net:
136+
driver: bridge
137+
138+
volumes:
139+
opensearch-data1:
140+
opensearch-data2:
141+
opensearch-data3:
142+
opensearch-snapshots:

CHANGELOG.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
88

99
- Enhanced cluster readiness checking for improved test reliability: `ostest.NewClient()` now includes readiness validation (health + cluster state + nodes info)
1010
- Configuration option `IncludeDedicatedClusterManagers` for controlling cluster manager node routing ([#765](https://github.com/opensearch-project/opensearch-go/issues/765))
11-
- Request-based connection routing for improved performance and service availability ([#770](https://github.com/opensearch-project/opensearch-go/pull/770))
12-
- `RequestAwareSelector` interface for operation-based node selection using http.Request directly
13-
- `RequestRoutingConnectionPool` interface extending ConnectionPool for request-based routing
14-
- `NewDefaultSelector()` providing intelligent routing with graceful fallback (recommended for most users)
15-
- `NewSmartSelector()` with comprehensive operation detection covering all OpenSearch REST API endpoints
16-
- `NewSelectorMux()` for custom HTTP pattern matching using `http.ServeMux`
17-
- `NewChainSelector()` implementing chain-of-responsibility pattern for composable routing strategies
18-
- `NewRoleBasedSelector()` with role-based selectors with `WithRequiredRoles()` and `WithExcludedRoles()` options
19-
- Automatic routing of bulk operations (including streaming bulk) to ingest nodes
20-
- Automatic routing of search operations (search, count, explain, by-query operations) to data nodes
21-
- Automatic routing of document retrieval operations (get, mget, source, termvectors) to data nodes for read locality
22-
- O(1) role lookup optimization using role sets instead of O(n) slice operations
11+
- Policy-based routing system for improved request routing and service availability ([#771](https://github.com/opensearch-project/opensearch-go/pull/771))
12+
- `Policy` interface for composable routing strategies with lifecycle management
13+
- `Router` interface with `Route()` method for request-based connection selection
14+
- `NewPolicy()` implementing chain-of-responsibility pattern for composable routing strategies
15+
- `NewIfEnabledPolicy()` for conditional routing with runtime evaluation
16+
- `NewMuxPolicy()` for custom HTTP pattern matching using `http.ServeMux`
17+
- `NewRolePolicy()` for role-based node selection
18+
- `NewDefaultRouter()` with coordinating node preference and round-robin fallback
19+
- `NewSmartRouter()` providing smart request routing with graceful fallback (recommended for most users)
20+
- Automatic routing of bulk operations (including streaming bulk) to ingest nodes
21+
- Automatic routing of search operations (search, count, explain, by-query operations) to data nodes
22+
- Automatic routing of document retrieval operations (get, mget, source, termvectors) to data nodes for read locality
2323

2424
### Changed
2525

0 commit comments

Comments
 (0)