Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster load: Refresh prometheus_api connection in case of connection error #11327

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions ocs_ci/ocs/cluster_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import logging
import time
import requests
from datetime import datetime
from uuid import uuid4
import math
Expand Down Expand Up @@ -353,11 +354,24 @@ def get_query(self, query, mute_logs=False):
"""
now = datetime.now
timestamp = datetime.timestamp
return float(
self.prometheus_api.query(
query, str(timestamp(now())), mute_logs=mute_logs, log_debug=True
)[0]["value"][1]
)
try:
result = float(
self.prometheus_api.query(
query, str(timestamp(now())), mute_logs=mute_logs, log_debug=True
)[0]["value"][1]
)
except (requests.exceptions.RequestException, IndexError) as e:
logger.info(
f"Encountered error: {e}. Refreshing connection and retrying..."
)
self.prometheus_api.refresh_connection()
result = float(
self.prometheus_api.query(
query, str(timestamp(now())), mute_logs=mute_logs, log_debug=True
)[0]["value"][1]
)

return result

def calc_trim_metric_mean(self, metric, samples=5, mute_logs=False):
"""
Expand Down