Browse Source

Add per-instance UUID to parsable status outputs

This is to help deduplicate instances when some are anycast or have multiple
IP addresses.
Ask Bjørn Hansen 10 years ago
parent
commit
a4ba74b142
3 changed files with 12 additions and 4 deletions
  1. 0 1
      build
  2. 8 3
      geodns.go
  3. 4 0
      monitor.go

+ 0 - 1
build

@@ -1,5 +1,4 @@
 #!/bin/sh
 #!/bin/sh
-#go get -v
 REVISION=`git rev-parse --short=5  HEAD`
 REVISION=`git rev-parse --short=5  HEAD`
 BUILDTIME=`TZ=UTC date "+%Y-%m-%dT%H:%MZ"`
 BUILDTIME=`TZ=UTC date "+%Y-%m-%dT%H:%MZ"`
 echo $REVISION > REVISION
 echo $REVISION > REVISION

+ 8 - 3
geodns.go

@@ -28,6 +28,8 @@ import (
 	"runtime/pprof"
 	"runtime/pprof"
 	"strings"
 	"strings"
 	"time"
 	"time"
+
+	"github.com/pborman/uuid"
 )
 )
 
 
 // VERSION is the current version of GeoDNS
 // VERSION is the current version of GeoDNS
@@ -39,9 +41,12 @@ var gitVersion string
 // templates from disk instead of from the binary.
 // templates from disk instead of from the binary.
 var development bool
 var development bool
 
 
-var serverID string
-var serverIP string
-var serverGroups []string
+var (
+	serverID     string
+	serverIP     string
+	serverGroups []string
+	serverUUID   = uuid.New()
+)
 
 
 var timeStarted = time.Now()
 var timeStarted = time.Now()
 
 

+ 4 - 0
monitor.go

@@ -25,6 +25,7 @@ type statusStreamMsgStart struct {
 	Version  string   `json:"v"`
 	Version  string   `json:"v"`
 	ID       string   `json:"id"`
 	ID       string   `json:"id"`
 	IP       string   `json:"ip"`
 	IP       string   `json:"ip"`
+	UUID     string   `json:"uuid"`
 	Uptime   int      `json:"up"`
 	Uptime   int      `json:"up"`
 	Started  int      `json:"started"`
 	Started  int      `json:"started"`
 	Groups   []string `json:"groups"`
 	Groups   []string `json:"groups"`
@@ -140,6 +141,7 @@ func initialStatus() string {
 	status.Version = VERSION
 	status.Version = VERSION
 	status.ID = serverID
 	status.ID = serverID
 	status.IP = serverIP
 	status.IP = serverIP
+	status.UUID = serverUUID
 	if len(serverGroups) > 0 {
 	if len(serverGroups) > 0 {
 		status.Groups = serverGroups
 		status.Groups = serverGroups
 	}
 	}
@@ -284,6 +286,7 @@ func StatusJSONHandler(zones Zones) func(http.ResponseWriter, *http.Request) {
 			Global   metrics.Registry
 			Global   metrics.Registry
 			ID       string
 			ID       string
 			IP       string
 			IP       string
+			UUID     string
 			Groups   []string
 			Groups   []string
 		}
 		}
 
 
@@ -297,6 +300,7 @@ func StatusJSONHandler(zones Zones) func(http.ResponseWriter, *http.Request) {
 			Global:   metrics.DefaultRegistry,
 			Global:   metrics.DefaultRegistry,
 			ID:       serverID,
 			ID:       serverID,
 			IP:       serverIP,
 			IP:       serverIP,
+			UUID:     serverUUID,
 			Groups:   serverGroups,
 			Groups:   serverGroups,
 		}
 		}