Copilot commented on code in PR #174:
URL: https://github.com/apache/solr-orbit/pull/174#discussion_r4762655120
##########
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:
The converter still lists `cluster-health` in `_UNSUPPORTED_OPS`
(`solrorbit/conversion/workload_converter.py:192`), so operation-list
conversions discard named health operations rather than preserving them as
described. Those converted workloads cannot use the new runner and can retain
unresolved schedule references. Remove this type from the unsupported set and
test that conversion preserves the operation and its schedule reference.
##########
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:
Setting `wait_for_no_relocating_shards` to `false` or `"false"` still
enables this condition because only key presence is checked. A recovering
replica then makes the check fail even when the requested health threshold is
satisfied. Parse the parameter's boolean value instead.
##########
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:
The generated procedure templates pass `index` as a comma-joined list. For
healthy collections `a` and `b`, this looks up the literal key `a,b`, reports
red, and waits indefinitely with `retry-until-success`. Split the target names
and aggregate their health, retaining red for any missing collection.
--
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]