Skip to content

Commit 9b40205

Browse files
authored
Merge pull request #184 from mwestphall/feature/submit-host-probe-name
Parse the hostname from APEL records' SubmitHost rather than SiteName
2 parents cbb05d8 + e80cdd1 commit 9b40205

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

kubernetes/kubernetes_meter.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import gratia.common.GratiaWrapper as GratiaWrapper
1414
import gratia.common.Gratia as Gratia
1515
import gratia.common.config as config
16+
from urllib.parse import urlparse
1617

1718
probe_version = "%%%RPMVERSION%%%"
1819

@@ -55,8 +56,15 @@ def get(self, key):
5556

5657

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

6169
def to_gratia_record(self):
6270
# TODO the following fields are not currently tracked:

0 commit comments

Comments
 (0)