|
|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
|
"net"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"regexp"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"sync"
|
|
|
|
@ -35,6 +36,11 @@ const (
|
|
|
|
|
"service, but no reason was provided. This is a default message."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// serviceNameRe checks if a service name is compatible with DNS.
|
|
|
|
|
serviceNameRe = regexp.MustCompile(`^[a-zA-Z0-9\-]+$`)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
The agent is the long running process that is run on every machine.
|
|
|
|
|
It exposes an RPC interface that is used by the CLI to control the
|
|
|
|
@ -595,6 +601,12 @@ func (a *Agent) AddService(service *structs.NodeService, chkTypes CheckTypes, pe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Warn if the service name is incompatible with DNS
|
|
|
|
|
if !serviceNameRe.MatchString(service.Service) {
|
|
|
|
|
a.logger.Printf("[WARN] Service name %q will not be discoverable "+
|
|
|
|
|
"via DNS due to invalid characters", service.Service)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the service
|
|
|
|
|
a.state.AddService(service)
|
|
|
|
|
|
|
|
|
|