Skip to content

Commit

Permalink
Merge pull request #2445 from weaveworks/1550-disable-weave-dns
Browse files Browse the repository at this point in the history
allow disabling of weaveDNS advertising/lookup
  • Loading branch information
rade authored Apr 15, 2017
2 parents 460352d + 413dbc7 commit 5c452d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions prog/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ func appMain(flags appFlags) {
}
})

// Periodically try and register out IP address in WeaveDNS.
if flags.weaveEnabled {
// Periodically try and register our IP address in WeaveDNS.
if flags.weaveEnabled && flags.weaveHostname != "" {
weave, err := newWeavePublisher(
flags.dockerEndpoint, flags.weaveAddr,
flags.weaveHostname, flags.containerName)
Expand Down
14 changes: 9 additions & 5 deletions prog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func main() {
flag.BoolVar(&debug, "debug", false, "Force debug logging.")
flag.BoolVar(&dryRun, "dry-run", false, "Don't start scope, just parse the arguments. For internal use only.")
flag.BoolVar(&weaveEnabled, "weave", true, "Enable Weave Net integrations.")
flag.StringVar(&weaveHostname, "weave.hostname", "", "Hostname to advertise/lookup in WeaveDNS")
flag.StringVar(&weaveHostname, "weave.hostname", app.DefaultHostname, "Hostname to advertise/lookup in WeaveDNS")

// We need to know how to parse them, but they are mainly interpreted by the entrypoint script.
// They are also here so they are included in usage, and the probe uses them to decide if to
Expand Down Expand Up @@ -321,7 +321,7 @@ func main() {

// Weave
flag.StringVar(&flags.probe.weaveAddr, "probe.weave.addr", "127.0.0.1:6784", "IP address & port of the Weave router")
flag.StringVar(&flags.probe.weaveHostname, "probe.weave.hostname", app.DefaultHostname, "Hostname to lookup in WeaveDNS")
flag.StringVar(&flags.probe.weaveHostname, "probe.weave.hostname", "", "Hostname to lookup in WeaveDNS")

// App flags
flag.DurationVar(&flags.app.window, "app.window", 15*time.Second, "window")
Expand All @@ -333,7 +333,7 @@ func main() {
flag.BoolVar(&flags.app.logHTTPHeaders, "app.log.httpHeaders", false, "Log HTTP headers. Needs app.log.http to be enabled.")

flag.StringVar(&flags.app.weaveAddr, "app.weave.addr", app.DefaultWeaveURL, "Address on which to contact WeaveDNS")
flag.StringVar(&flags.app.weaveHostname, "app.weave.hostname", app.DefaultHostname, "Hostname to advertise in WeaveDNS")
flag.StringVar(&flags.app.weaveHostname, "app.weave.hostname", "", "Hostname to advertise in WeaveDNS")
flag.StringVar(&flags.app.containerName, "app.container.name", app.DefaultContainerName, "Name of this container (to lookup container ID)")
flag.StringVar(&flags.app.dockerEndpoint, "app.docker", app.DefaultDockerEndpoint, "Location of docker endpoint (to lookup container ID)")
flag.Var(&containerLabelFilterFlags, "app.container-label-filter", "Add container label-based view filter, specified as title:label. Multiple flags are accepted. Example: --app.container-label-filter='Database Containers:role=db'")
Expand Down Expand Up @@ -369,8 +369,12 @@ func main() {
flags.app.logLevel = "debug"
}
if weaveHostname != "" {
flags.probe.weaveHostname = weaveHostname
flags.app.weaveHostname = weaveHostname
if flags.probe.weaveHostname == "" {
flags.probe.weaveHostname = weaveHostname
}
if flags.app.weaveHostname == "" {
flags.app.weaveHostname = weaveHostname
}
}
flags.probe.weaveEnabled = weaveEnabled
flags.app.weaveEnabled = weaveEnabled
Expand Down
30 changes: 16 additions & 14 deletions prog/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,26 @@ func probeMain(flags probeFlags, targets []appclient.Target) {
p.AddTagger(weave)
p.AddReporter(weave)

dockerBridgeIP, err := network.GetFirstAddressOf(flags.dockerBridge)
if err != nil {
log.Errorf("Error getting docker bridge ip: %v", err)
} else {
weaveDNSLookup := appclient.LookupUsing(dockerBridgeIP + ":53")
weaveTargets, err := appclient.ParseTargets([]string{flags.weaveHostname})
if flags.weaveHostname != "" {
dockerBridgeIP, err := network.GetFirstAddressOf(flags.dockerBridge)
if err != nil {
log.Errorf("Failed to parse weave targets: %v", err)
log.Errorf("Error getting docker bridge ip: %v", err)
} else {
weaveResolver, err := appclient.NewResolver(appclient.ResolverConfig{
Targets: weaveTargets,
Lookup: weaveDNSLookup,
Set: clients.Set,
})
weaveDNSLookup := appclient.LookupUsing(dockerBridgeIP + ":53")
weaveTargets, err := appclient.ParseTargets([]string{flags.weaveHostname})
if err != nil {
log.Errorf("Failed to create weave resolver: %v", err)
log.Errorf("Failed to parse weave targets: %v", err)
} else {
defer weaveResolver.Stop()
weaveResolver, err := appclient.NewResolver(appclient.ResolverConfig{
Targets: weaveTargets,
Lookup: weaveDNSLookup,
Set: clients.Set,
})
if err != nil {
log.Errorf("Failed to create weave resolver: %v", err)
} else {
defer weaveResolver.Stop()
}
}
}
}
Expand Down

0 comments on commit 5c452d0

Please sign in to comment.