From d1ad17d01a818cad989280ab0274c8b230aa3286 Mon Sep 17 00:00:00 2001 From: LeaveMyYard Date: Tue, 30 Apr 2024 18:54:43 +0300 Subject: Minor additional logging improvements --- robusta_krr/core/integrations/prometheus/connector.py | 11 +++-------- robusta_krr/core/runner.py | 2 ++ robusta_krr/main.py | 12 ++++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/robusta_krr/core/integrations/prometheus/connector.py b/robusta_krr/core/integrations/prometheus/connector.py index d75050f..8020c2e 100644 --- a/robusta_krr/core/integrations/prometheus/connector.py +++ b/robusta_krr/core/integrations/prometheus/connector.py @@ -58,14 +58,9 @@ class PrometheusConnector: def connect(self, url: Optional[str] = None) -> None: """Connect to a Prometheus service using a URL.""" - try: - loader = PrometheusMetricsService(url=url) - self._connect(loader) - except Exception as e: - logger.warning(f"Unable to connect to Prometheus using the provided URL ({e})") - raise e - else: - logger.info(f"{loader.name()} connected successfully") + loader = PrometheusMetricsService(url=url) + self._connect(loader) + logger.info(f"{loader.name()} connected successfully") def _connect(self, loader: PrometheusMetricsService) -> None: service_name = loader.name() diff --git a/robusta_krr/core/runner.py b/robusta_krr/core/runner.py index 75c2191..a52f1be 100644 --- a/robusta_krr/core/runner.py +++ b/robusta_krr/core/runner.py @@ -247,6 +247,8 @@ class Runner: async def _collect_result(self) -> Result: clusters = await self.connector.list_clusters() + logger.info(f"Clusters available: {', '.join(clusters)}") + if clusters and len(clusters) > 1 and settings.prometheus_url: # this can only happen for multi-cluster querying a single centeralized prometheus # In this scenario we dont yet support determining diff --git a/robusta_krr/main.py b/robusta_krr/main.py index 6fc0f1f..c64c0f4 100644 --- a/robusta_krr/main.py +++ b/robusta_krr/main.py @@ -53,7 +53,7 @@ def load_commands() -> None: "--kubeconfig", "-k", help="Path to kubeconfig file. If not provided, will attempt to find it.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), mode: LoadingMode = typer.Option( LoadingMode.KUBEAPI, @@ -67,13 +67,13 @@ def load_commands() -> None: None, "--as", help="Impersonate a user, just like `kubectl --as`. For example, system:serviceaccount:default:krr-account.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), impersonate_group: Optional[str] = typer.Option( None, "--as-group", help="Impersonate a user inside of a group, just like `kubectl --as-group`. For example, system:authenticated.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), clusters: List[str] = typer.Option( None, @@ -81,13 +81,13 @@ def load_commands() -> None: "--cluster", "-c", help="List of clusters to run on. By default, will run on the current cluster. Use --all-clusters to run on all clusters.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), all_clusters: bool = typer.Option( False, "--all-clusters", help="Run on all clusters. Overrides --context.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), namespaces: List[str] = typer.Option( None, @@ -108,7 +108,7 @@ def load_commands() -> None: "--selector", "-s", help="Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -s key1=value1,key2=value2). Matching objects must satisfy all of the specified label constraints.", - rich_help_panel="Kubernetes Settings", + rich_help_panel="KubeAPI Mode Settings", ), prometheus_url: Optional[str] = typer.Option( None, -- cgit v1.2.3