Skip to content

Commit f6878cf

Browse files
authored
[ROB-2094] added supabase conectivity log and instructions on failure (#1949)
* added supabase conectivity log and instructions on failure * update error message * swallowing stack trace and changing message * fix indentation
1 parent d0eea9f commit f6878cf

4 files changed

Lines changed: 45 additions & 8 deletions

File tree

src/robusta/core/exceptions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ class NoAlertManagerUrlFound(Exception):
1414
"""Exception, when AlertManager url is incorrect"""
1515

1616
pass
17+
18+
19+
class SupabaseDnsException(Exception):
20+
"""Exception for Supabase DNS/connectivity issues (host resolution / firewall).
21+
22+
Raised when the runner cannot resolve or connect to the configured Supabase URL.
23+
"""
24+
def __init__(self, original_exception: Exception, url: str):
25+
message = (
26+
f"\n{original_exception.__class__.__name__}: {original_exception}\n"
27+
f"Error connecting to {url}\n"
28+
f"This is often due to DNS issues or firewall policies - to troubleshoot run in your cluster:\n"
29+
f"curl -I {url}"
30+
)
31+
super().__init__(message)
32+
self.original_exception = original_exception
33+
self.url = url

src/robusta/core/sinks/robusta/dal/supabase_dal.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import threading
77
from typing import Any, Dict, List, Optional, Tuple
88
from uuid import uuid4
9-
109
from cachetools import TTLCache
1110
import requests
1211
from postgrest._sync.request_builder import SyncQueryRequestBuilder
@@ -18,6 +17,7 @@
1817
from supabase.lib.client_options import ClientOptions
1918

2019
from robusta.core.model.cluster_status import ClusterStatus
20+
from robusta.core.exceptions import SupabaseDnsException
2121
from robusta.core.model.env_vars import SUPABASE_TIMEOUT_SECONDS
2222
from robusta.core.model.helm_release import HelmRelease
2323
from robusta.core.model.jobs import JobInfo
@@ -555,10 +555,24 @@ def publish_helm_releases(self, helm_releases: List[HelmRelease]):
555555

556556
def sign_in(self) -> str:
557557
logging.info("Supabase dal login")
558-
res = self.client.auth.sign_in_with_password({"email": self.email, "password": self.password})
559-
self.client.auth.set_session(res.session.access_token, res.session.refresh_token)
560-
self.client.postgrest.auth(res.session.access_token)
561-
return res.user.id
558+
try:
559+
res = self.client.auth.sign_in_with_password({"email": self.email, "password": self.password})
560+
self.client.auth.set_session(res.session.access_token, res.session.refresh_token)
561+
self.client.postgrest.auth(res.session.access_token)
562+
return res.user.id
563+
except Exception as e:
564+
# Check if this is a DNS-related error
565+
error_msg = str(e).lower()
566+
if any(dns_indicator in error_msg for dns_indicator in [
567+
"temporary failure in name resolution",
568+
"name resolution",
569+
"dns",
570+
"name or service not known",
571+
"nodename nor servname provided"
572+
]):
573+
dns_exc = SupabaseDnsException(e, self.url)
574+
raise dns_exc from e
575+
raise
562576

563577
def to_db_cluster_status(self, data: ClusterStatus) -> Dict[str, Any]:
564578
db_cluster_status = data.dict()

src/robusta/model/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from robusta.core.pubsub.events_pubsub import EventsPubSub
1212
from robusta.core.sinks.robusta.robusta_sink import RobustaSink
1313
from robusta.core.sinks.robusta.robusta_sink_params import RobustaSinkConfigWrapper, RobustaSinkParams
14+
from robusta.core.exceptions import SupabaseDnsException
1415
from robusta.core.sinks.sink_base import SinkBase
1516
from robusta.core.sinks.sink_config import SinkConfigBase
1617
from robusta.core.sinks.sink_factory import SinkFactory
@@ -91,7 +92,9 @@ def construct_new_sinks(
9192

9293
except Exception as e:
9394
has_sink_errors = True
94-
logging.error(f"Failed to initialize sink {sink_name}: {e}", exc_info=True)
95+
# Don't show trace for Robusta SaaS DNS-related exception to avoid hiding the error in noisy logs
96+
exec_info = not isinstance(e, SupabaseDnsException)
97+
logging.error(f"Failed to initialize sink {sink_name}: {e}", exc_info=exec_info)
9598
if not continue_on_sink_errors:
9699
raise
97100
# Skip this sink if continue_on_sink_errors is True

src/robusta/runner/config_loader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from robusta.model.playbook_definition import PlaybookDefinition
4444
from robusta.utils.cluster_provider_discovery import cluster_provider
4545
from robusta.utils.file_system_watcher import FileSystemWatcher
46+
from robusta.core.exceptions import SupabaseDnsException
4647

4748

4849
class ConfigLoader:
@@ -271,10 +272,12 @@ def __reload_playbook_packages(self, change_name):
271272
str(runner_config.global_config.get("cluster_name", "no_cluster")).encode("utf-8")
272273
).hexdigest()
273274

274-
except Exception:
275+
except Exception as e:
276+
print_exception = not isinstance(e, SupabaseDnsException) # Don't show trace for Robusta SaaS DNS-related exception to avoid hiding the error in noisy logs
277+
275278
logging.error(
276279
"Error (re)loading playbooks/related resources, exiting.",
277-
exc_info=True,
280+
exc_info=print_exception,
278281
)
279282
# Kill the whole process group (which means this process and all of its descendant
280283
# processes). The rest of the runner shutdown happens in robusta.runner.process_setup.

0 commit comments

Comments
 (0)