Skip to content

Commit

Permalink
Require PROMETHEUS_URL be set, don't hard-code default
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnesbitt committed Jan 17, 2024
1 parent 2fb0190 commit cd8879d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion analytics/analytics/job_processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_job(gl: gitlab.Gitlab, project: Project, gljob: ProjectJob) -> Job:

# Prometheus data will either be found and the job annotated, or not, and set aws to False
try:
PrometheusClient(settings.SPACK_PROMETHEUS_ENDPOINT).annotate_job(job=job)
PrometheusClient(settings.PROMETHEUS_URL).annotate_job(job=job)

# Ensure node creation isn't caught in a race condition
job.save_or_set_node()
Expand Down
8 changes: 1 addition & 7 deletions analytics/analytics/job_processor/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

from analytics.models import Job, JobPod, Node

CLUSTER_INTERNAL_PROMETHEUS_URL = (
"kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090"
)
PROM_MAX_RESOLUTION = 10_000


Expand Down Expand Up @@ -51,10 +48,7 @@ def calculate_node_occupancy(data: list[dict], step: int):


class PrometheusClient:
def __init__(self, url: str | None = None) -> None:
if url is None:
url = CLUSTER_INTERNAL_PROMETHEUS_URL

def __init__(self, url: str) -> None:
self.api_url = f"{url.rstrip('/')}/api/v1"

def query_single(self, query: str, time: datetime):
Expand Down
2 changes: 1 addition & 1 deletion analytics/analytics/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
GITLAB_ENDPOINT: str = os.environ["GITLAB_ENDPOINT"]
GITLAB_TOKEN: str = os.environ["GITLAB_TOKEN"]

SPACK_PROMETHEUS_ENDPOINT: str = os.environ.get("SPACK_PROMETHEUS_ENDPOINT")
PROMETHEUS_URL: str = os.environ["PROMETHEUS_URL"]
1 change: 1 addition & 0 deletions analytics/dev/.env.docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CELERY_BROKER_URL=redis://localhost:6379/0
SECRET_KEY=deadbeef
GITLAB_ENDPOINT="http://fakeurl"
GITLAB_TOKEN="bar"
PROMETHEUS_URL="http://localhost:9090
4 changes: 4 additions & 0 deletions k8s/production/custom/webhook-handler/deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ spec:
secretKeyRef:
name: webhook-secrets
key: celery-broker-url
- name: PROMETHEUS_URL
value: kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
nodeSelector:
spack.io/node-pool: base

Expand Down Expand Up @@ -182,5 +184,7 @@ spec:
secretKeyRef:
name: webhook-secrets
key: celery-broker-url
- name: PROMETHEUS_URL
value: kube-prometheus-stack-prometheus.monitoring.svc.cluster.local:9090
nodeSelector:
spack.io/node-pool: base

0 comments on commit cd8879d

Please sign in to comment.