From 08205f281d2f82cb0a57caba0639f2aa1729bc83 Mon Sep 17 00:00:00 2001 From: shabbywu Date: Tue, 5 Mar 2024 15:41:25 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E5=AF=B9=E6=8E=A5=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apiserver/paasng/paasng/accessories/log/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apiserver/paasng/paasng/accessories/log/client.py b/apiserver/paasng/paasng/accessories/log/client.py index d07db7d196..0730e5b6b8 100644 --- a/apiserver/paasng/paasng/accessories/log/client.py +++ b/apiserver/paasng/paasng/accessories/log/client.py @@ -95,14 +95,19 @@ def execute_scroll_search( "scenario_id": self.config.scenarioID, "body": search.to_dict(), "scroll": scroll, + # TODO: -1 是日志平台提供的跳过参数的占位值. 待日志平台移除对该参数的必要校验后, 移除该参数. + "storage_cluster_id": -1, } if scroll_id: data["scroll_id"] = scroll_id resp = self._call_api(self._esclient.esquery_scroll, data=data, timeout=timeout) else: - raise NotImplementedError(_("esquery_dsl 目前不支持 scroll 参数")) resp = self._call_api(self._esclient.esquery_dsl, data=data, timeout=timeout) - # TODO: 处理 scroll_id 不存在的报错 + + if not resp["result"]: + # 有可能是 scroll id 失效了, 反正抛异常就对了 + raise ScanError(scroll_id, "Scroll request has failed on `{}`".format(resp["message"])) + response = Response(search.search, resp["data"]) total = resp["data"]["hits"]["total"] return response, total