Skip to content

Commit

Permalink
pull default config from env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
arikalon1 committed May 31, 2024
1 parent b548ab1 commit d3475be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/robusta/core/model/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def load_bool(env_var, default: bool):
# lowered case k8s kinds in a json array string. "[\"configmap\", \"secret\"]"
RESOURCE_YAML_BLOCK_LIST = json.loads(os.environ.get("RESOURCE_YAML_BLOCK_LIST", "[]"))

NAMESPACE_DATA_TTL = int(os.environ.get("NAMESPACE_DATA_TTL", 30*60)) # in seconds
NAMESPACE_DATA_TTL = int(os.environ.get("NAMESPACE_DATA_TTL", 30 * 60)) # in seconds

PROCESSED_ALERTS_CACHE_TTL = int(os.environ.get("PROCESSED_ALERT_CACHE_TTL", 2*3600))
PROCESSED_ALERTS_CACHE_TTL = int(os.environ.get("PROCESSED_ALERT_CACHE_TTL", 2 * 3600))
PROCESSED_ALERTS_CACHE_MAX_SIZE = int(os.environ.get("PROCESSED_ALERTS_CACHE_MAX_SIZE", 100_000))

POD_WAIT_RETRIES = int(os.environ.get("POD_WAIT_RETRIES", 10))
POD_WAIT_RETRIES_SECONDS = int(os.environ.get("POD_WAIT_RETRIES_SECONDS", 5))
11 changes: 9 additions & 2 deletions src/robusta/integrations/kubernetes/custom_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
from kubernetes.client import ApiException
from pydantic import BaseModel

from robusta.core.model.env_vars import IMAGE_REGISTRY, INSTALLATION_NAMESPACE, RUNNER_SERVICE_ACCOUNT
from robusta.core.model.env_vars import (
IMAGE_REGISTRY,
INSTALLATION_NAMESPACE,
POD_WAIT_RETRIES,
POD_WAIT_RETRIES_SECONDS,
RUNNER_SERVICE_ACCOUNT,
)
from robusta.integrations.kubernetes.api_client_utils import (
SUCCEEDED_STATE,
exec_shell_command,
Expand Down Expand Up @@ -451,9 +457,10 @@ def get_pods(self) -> List[RobustaPod]:
# we serialize and then deserialize to work around https://github.com/haxsaw/hikaru/issues/15
return [hikaru.from_dict(pod.to_dict(), cls=RobustaPod) for pod in pods.items]

def get_single_pod(self, retries: int = 10, wait: int = 5) -> RobustaPod:
def get_single_pod(self, retries: int = POD_WAIT_RETRIES, wait: int = POD_WAIT_RETRIES_SECONDS) -> RobustaPod:
"""
like get_pods() but verifies that only one pod is associated with the job and returns that pod
if no pods, retry X times with Y seconds wait
"""
pods = self.get_pods()
while retries > 0 and len(pods) == 0:
Expand Down

0 comments on commit d3475be

Please sign in to comment.