serhiy-bzhezytskyy commented on code in PR #174:
URL: https://github.com/apache/solr-orbit/pull/174#discussion_r4767117221
##########
solrorbit/worker_coordinator/runner.py:
##########
@@ -66,6 +66,7 @@ def register_default_runners():
register_runner("create-collection", SolrCreateCollection(),
async_runner=True)
register_runner("delete-collection", SolrDeleteCollection(),
async_runner=True)
register_runner("raw-request", RawRequest(), async_runner=True)
+ register_runner("cluster-health", Retry(SolrClusterHealth()),
async_runner=True)
Review Comment:
That entry is on this branch only because it predates #177, which took
`cluster-health` out of the unsupported list on `main`. With this merged, the
converter keeps the operation and this runner handles it, so nothing changes
here.
##########
solrorbit/worker_coordinator/runner.py:
##########
@@ -1385,6 +1386,65 @@ def __str__(self):
return "solr-optimize"
+# ---------------------------------------------------------------------------
+# Runner: cluster-health
+# ---------------------------------------------------------------------------
+
+_HEALTH_ORDER = {"red": 0, "yellow": 1, "green": 2}
+# Solr's own collection health (CLUSTERSTATUS, SOLR-15300); YELLOW and ORANGE
both still have a leader
+_SOLR_HEALTH = {"GREEN": "green", "YELLOW": "yellow", "ORANGE": "yellow",
"RED": "red"}
+
+
+class SolrClusterHealth(SolrRunner):
+ """
+ Check a collection's health the way OpenSearch Benchmark's
``cluster-health`` checks an index.
+
+ Params:
+ - ``collection`` (default: every collection in the cluster)
+ - ``request-params``: ``wait_for_status`` (``green``, ``yellow`` or
``red``; default: no
+ expectation) and ``wait_for_no_relocating_shards``
+ - ``retry-until-success``: repeat until the expectation holds (handled
by ``Retry``)
+
+ The status is the ``health`` CLUSTERSTATUS reports for each collection,
which Solr computes after
+ marking the replicas of dead nodes down: GREEN is green, YELLOW and ORANGE
are yellow, RED is red.
+ A missing collection is red, and a recovering replica counts as a
relocating shard.
+ """
+
+ async def __call__(self, client, params):
+ request_params = params.get("request-params", {})
+ expected = str(request_params.get("wait_for_status", "red")).lower()
+ if expected not in _HEALTH_ORDER:
+ raise exceptions.DataError("Unknown wait_for_status [%s]" %
expected)
+ no_relocating = "wait_for_no_relocating_shards" in request_params
Review Comment:
OpenSearch Benchmark's own runner enables this check by the presence of the
key, whatever its value (`osbenchmark/worker_coordinator/runner.py:1920`: `if
"wait_for_no_relocating_shards" in request_params`), and every use in the
upstream workloads is `"true"`. This runner follows it, so it is left as it is.
##########
solrorbit/worker_coordinator/runner.py:
##########
@@ -1385,6 +1386,65 @@ def __str__(self):
return "solr-optimize"
+# ---------------------------------------------------------------------------
+# Runner: cluster-health
+# ---------------------------------------------------------------------------
+
+_HEALTH_ORDER = {"red": 0, "yellow": 1, "green": 2}
+# Solr's own collection health (CLUSTERSTATUS, SOLR-15300); YELLOW and ORANGE
both still have a leader
+_SOLR_HEALTH = {"GREEN": "green", "YELLOW": "yellow", "ORANGE": "yellow",
"RED": "red"}
+
+
+class SolrClusterHealth(SolrRunner):
+ """
+ Check a collection's health the way OpenSearch Benchmark's
``cluster-health`` checks an index.
+
+ Params:
+ - ``collection`` (default: every collection in the cluster)
+ - ``request-params``: ``wait_for_status`` (``green``, ``yellow`` or
``red``; default: no
+ expectation) and ``wait_for_no_relocating_shards``
+ - ``retry-until-success``: repeat until the expectation holds (handled
by ``Retry``)
+
+ The status is the ``health`` CLUSTERSTATUS reports for each collection,
which Solr computes after
+ marking the replicas of dead nodes down: GREEN is green, YELLOW and ORANGE
are yellow, RED is red.
+ A missing collection is red, and a recovering replica counts as a
relocating shard.
+ """
+
+ async def __call__(self, client, params):
+ request_params = params.get("request-params", {})
+ expected = str(request_params.get("wait_for_status", "red")).lower()
+ if expected not in _HEALTH_ORDER:
+ raise exceptions.DataError("Unknown wait_for_status [%s]" %
expected)
+ no_relocating = "wait_for_no_relocating_shards" in request_params
+ target = params.get("collection") or params.get("index")
+
+ start = time.perf_counter()
+ collections = (await
_run_in_executor(client.get_clusterstatus))["cluster"].get("collections", {})
+ if target:
+ collections = {target: collections[target]} if target in
collections else {}
Review Comment:
Confirmed with two healthy collections and `index: "a,b"`: the status was
red and `retry-until-success` would not have stopped. Fixed in 380dc1fa: each
name is looked up on its own, the status is the worst of them, and a name that
is not in the cluster is red. The converter does not generate such a list, but
OpenSearch Benchmark's `index` allows one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]