Skip to content

Commit 756afdc

Browse files
Merge pull request #170 from m-lab/soltesz-fix-hostname
Fix NDT server_hostname when missing from connSpec
2 parents d7d250d + 110a720 commit 756afdc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

etl/globals.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const dateTime = `(\d{4}[01]\d[0123]\d)T000000Z`
1111
const mlabN_podNN = `-(mlab\d)-([[:alpha:]]{3}\d[0-9t])-`
1212
const exp_NNNN = `(.*)-(\d{4})`
1313
const suffix = `(?:\.tar|\.tar.gz|\.tgz)$`
14+
const MlabDomain = `measurement-lab.org`
1415

1516
// These are here to facilitate use across queue-pusher and parsing components.
1617
var (

parser/ndt.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package parser
33
import (
44
"encoding/json"
55
"errors"
6+
"fmt"
67
"log"
78
"regexp"
89
"strings"
@@ -502,7 +503,7 @@ func (n *NDTParser) getAndInsertValues(test *fileInfoAndData, testType string) {
502503
}
503504
results["connection_spec"] = connSpec
504505

505-
fixValues(results)
506+
n.fixValues(results)
506507
// TODO fix InsertRow so that we can distinguish errors from prior rows.
507508
metrics.EntryFieldCountHistogram.WithLabelValues(n.TableName()).
508509
Observe(float64(deltaFieldCount))
@@ -547,7 +548,7 @@ const (
547548
// fixValues updates web100 log values that need post-processing fix-ups.
548549
// TODO(dev): does this only apply to NDT or is NPAD also affected?
549550
// TODO(dev) - consider improving test coverage.
550-
func fixValues(r schema.Web100ValueMap) {
551+
func (n *NDTParser) fixValues(r schema.Web100ValueMap) {
551552
connSpec := r.GetMap([]string{"connection_spec"})
552553
logEntry := r.GetMap([]string{"web100_log_entry"})
553554
snap := logEntry.GetMap([]string{"snap"})
@@ -560,6 +561,17 @@ func fixValues(r schema.Web100ValueMap) {
560561
delete(connSpec, "client_hostname")
561562
}
562563

564+
// If there is no meta file then the server hostname will not be set.
565+
if connSpec["server_hostname"] == "" {
566+
data, err := etl.ValidateTestPath(n.taskFileName)
567+
if err != nil {
568+
log.Println("WARNING: taskFileName is unexpectedly invalid.")
569+
} else {
570+
connSpec["server_hostname"] = fmt.Sprintf(
571+
"%s.%s.%s", data.Host, data.Pod, etl.MlabDomain)
572+
}
573+
}
574+
563575
// snapshot addresses are always authoritative. Other sources don't handle
564576
// ipv6 correctly. So, always substitute, unless for some reason the snapshot
565577
// value is missing.

0 commit comments

Comments
 (0)