Skip to content

Commit

Permalink
Assume no operator if security not enabled in serverless (#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbanasiak authored May 29, 2024
1 parent fc8822e commit 6706bec
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions esrally/client/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import contextlib
import logging
import time

Expand Down Expand Up @@ -363,12 +364,19 @@ def cluster_distribution_version(hosts, client_options, client_factory=EsClientF
# if version number is not available default to build flavor
version_number = version.get("number", version_build_flavor)

# assume non-operator serverless privileges by default
serverless_operator = False
if versions.is_serverless(version_build_flavor):
# overwrite static serverless version number
version_number = "serverless"
authentication_info = es.perform_request(method="GET", path="/_security/_authenticate")
serverless_operator = authentication_info.body.get("operator", False)

# determine serverless operator status if security enabled
# pylint: disable=import-outside-toplevel
from elasticsearch.exceptions import ApiError

with contextlib.suppress(ApiError):
authentication_info = es.perform_request(method="GET", path="/_security/_authenticate")
serverless_operator = authentication_info.body.get("operator", False)

if not versions.is_serverless(version_build_flavor) or serverless_operator is True:
# if available, unconditionally wait for the REST layer - if it's not up, we'll intentionally raise the original error
Expand Down

0 comments on commit 6706bec

Please sign in to comment.