mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
agent: warn on service tags with invalid chars
This commit is contained in:
parent
5e801c905d
commit
722b255816
@ -37,8 +37,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// serviceNameRe checks if a service name is compatible with DNS.
|
// dnsNameRe checks if a name or tag is dns-compatible.
|
||||||
serviceNameRe = regexp.MustCompile(`^[a-zA-Z0-9\-]+$`)
|
dnsNameRe = regexp.MustCompile(`^[a-zA-Z0-9\-]+$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -602,11 +602,19 @@ func (a *Agent) AddService(service *structs.NodeService, chkTypes CheckTypes, pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warn if the service name is incompatible with DNS
|
// Warn if the service name is incompatible with DNS
|
||||||
if !serviceNameRe.MatchString(service.Service) {
|
if !dnsNameRe.MatchString(service.Service) {
|
||||||
a.logger.Printf("[WARN] Service name %q will not be discoverable "+
|
a.logger.Printf("[WARN] Service name %q will not be discoverable "+
|
||||||
"via DNS due to invalid characters", service.Service)
|
"via DNS due to invalid characters", service.Service)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn if any tags are incompatible with DNS
|
||||||
|
for _, tag := range service.Tags {
|
||||||
|
if !dnsNameRe.MatchString(tag) {
|
||||||
|
a.logger.Printf("[WARN] Service tag %q will not be discoverable "+
|
||||||
|
"via DNS due to invalid characters", tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add the service
|
// Add the service
|
||||||
a.state.AddService(service)
|
a.state.AddService(service)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user