Skip to content

Commit

Permalink
Merge pull request #184 from mwestphall/feature/submit-host-probe-name
Browse files Browse the repository at this point in the history
Parse the hostname from APEL records' SubmitHost rather than SiteName
  • Loading branch information
mwestphall authored Aug 15, 2024
2 parents cbb05d8 + e80cdd1 commit 9b40205
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kubernetes/kubernetes_meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gratia.common.GratiaWrapper as GratiaWrapper
import gratia.common.Gratia as Gratia
import gratia.common.config as config
from urllib.parse import urlparse

probe_version = "%%%RPMVERSION%%%"

Expand Down Expand Up @@ -55,8 +56,15 @@ def get(self, key):


def site_probe(self):
site_dns = re.sub(r'[^a-zA-Z0-9-]', '-', self.get('Site')).strip('-') # sanitize site
return "kubernetes:%s.gratia.osg-htc.org" % site_dns
""" Get the domain from the record's SubmitHost, removing scheme and path if present """
submit_host = self.get('SubmitHost')
# Hack: Make sure the submitHost starts with a protocol so urllib can parse it
if not re.match('[A-Za-z]*://', submit_host):
submit_host = f"https://{submit_host}"
probe_domain = urlparse(submit_host).hostname
if not probe_domain:
raise Exception(f"Unable to determine probe domain from submit host {self.get('SubmitHost')}")
return probe_domain

def to_gratia_record(self):
# TODO the following fields are not currently tracked:
Expand Down

0 comments on commit 9b40205

Please sign in to comment.