New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add builtin nodes discovery #16229
Add builtin nodes discovery #16229
Conversation
@icecrime is there a design doc that describes how this works? In particular, what is relationship with swarm? I wasn't aware that we were headed towards a single daemon knowing about other daemons. |
} | ||
|
||
// Watch is exported | ||
func (s *Discovery) Watch(stopCh <-chan struct{}) (<-chan discovery.Entries, <-chan error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know if it's overengineering for this case, but we could use inotify to avoid polling the file (at least on Linux).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or fsnotify which is cross-platform and already vendored... but still need to fallback to polling as I've seen multiple people with issues on docker logs -f
which is using inotify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but can be done in a separate PR as the engine won't use file
(only swarm uses it)
ff3626d
to
1454028
Compare
return []string{pattern} | ||
} | ||
|
||
template := re.ReplaceAllString(pattern, "%d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this will break with a pattern that matches the regexp multiple times. It will also behave strangely if the pattern includes a % character or a printf directive. I feel it's better to avoid using Sprintf
with a user-controlled format string.
@duglin Unfortunately, I don't have a design doc: let me try to summarize in a few sentences. Both Swarm and mutihost networking require nodes discovery. On the Swarm side, this is nicely done with a well delimited
This is an quick and easy way to provide such facility in the Engine. In the future, we could imagine exposing nodes membership changes as part of the |
7bf0ad4
to
b60e7ad
Compare
This is broken because |
I know how to fix PR will come when I get home On Thursday, September 10, 2015, Arnaud Porterie notifications@github.com
|
Is |
@LK4D4 this package is in swarm, we use testify in swarm. As soon as it's moved, we are going to remove it from swarm and vendor this one. |
Maybe we should look to releasing some cool libs under docker organization. Because as I see pkg is still unnoticed by community. Same for |
+1 for under a separate repo. |
@LK4D4 +1 to a spot for generic packages |
PR is update and rebased to fix the broken tests (thanks @jfrazelle)! |
As part of the concern on keeping this under |
+1 @abronan Tests are still broken, probably related to vendor pruning (reping @jfrazelle, sorry). |
+1 @abronan. |
@icecrime the test failures are due to the |
Absorb Swarm's discovery package in order to provide a common node discovery mechanism to be used by both Swarm and networking code. Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
Updated to take last discussions into account. Also rebased: with latest libkv/libnetwork change the tests should hopefully be green. |
|
||
// Creates a new store, will ignore options given | ||
// if not supported by the chosen store | ||
s.store, err = libkv.NewStore(s.backend, addrs, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hunch is this will probably have to come in a subsequent change, but it would be nice to support configuration settings for libkv. In particular, in multi-host environments, being able to set up ClientTLS configuration based on docker/libkv@e7f836c would be beneficial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhiltgen yes. this will come as a subsequent PR. also, we need to work with Darren on the PR to make this a 1-time dynamic configuration.
Use `pkg/discovery` to provide nodes discovery between daemon instances. The functionality is driven by two different command-line flags: the experimental `--cluster-store` (previously `--kv-store`) and `--cluster-advertise`. It can be used in two ways by interested components: 1. Externally by calling the `/info` API and examining the cluster store field. The `pkg/discovery` package can then be used to hit the same endpoint and watch for appearing or disappearing nodes. That is the method that will for example be used by Swarm. 2. Internally by using the `Daemon.discoveryWatcher` instance. That is the method that will for example be used by libnetwork. Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
LGTM, let's address enhancements and documentation in other PRs (like for the |
Thanks @icecrime. LGTM. |
@aluzzardi if you agree, we should merge this and that will unblock the dependent PRs. As discussed, the backend updates can be taken up in subsequent PRs. |
LGTM as well |
LGTM |
\o/ |
// ClusterStore is the storage backend used for the cluster information. It is used by both | ||
// multihost networking (to store networks and endpoints information) and by the node discovery | ||
// mechanism. | ||
ClusterStore string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, the convention in Go is to identify stringly-typed network endpoint fields with Addr
. This should be ClusterStoreAddr
.
Use
pkg/discovery
to provide nodes discovery between daemon instances.The functionality is driven by two different command-line flags:
--discovery-backend
and--discovery-address
. It can be used in twoways by interested components:
/info
API and examining the discoverybackend. The
pkg/discovery
package can then be used to hit the sameendpoint and watch for appearing or disappearing nodes. That is the
method that will for example be used by Swarm.
Daemon.discoveryWatcher
instance. That isthe method that will for example be used by libnetwork.
Ping @abronan @mavenugo @vieux.