Skip to content

Commit

Permalink
Minor additional logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed Apr 30, 2024
1 parent 7124c80 commit d1ad17d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
11 changes: 3 additions & 8 deletions robusta_krr/core/integrations/prometheus/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@ def discover(self, api_client: ApiClient) -> None:

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()
Expand Down
2 changes: 2 additions & 0 deletions robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ async def _gather_object_allocations(self, k8s_object: K8sWorkload) -> Optional[

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
Expand Down
12 changes: 6 additions & 6 deletions robusta_krr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run_strategy(
"--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,
Expand All @@ -67,27 +67,27 @@ def run_strategy(
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,
"--context",
"--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,
Expand All @@ -108,7 +108,7 @@ def run_strategy(
"--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,
Expand Down

0 comments on commit d1ad17d

Please sign in to comment.