The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4287
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 126377d999ae240194e60b4dbad806e5ea7900e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 27 Feb 2018 17:23:02 -0500 Subject: [PATCH 1/3] Fix double initialization of uevent handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxd/daemon.go | 20 +++++++++++--------- lxd/devices.go | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lxd/daemon.go b/lxd/daemon.go index ac319845c..805db9679 100644 --- a/lxd/daemon.go +++ b/lxd/daemon.go @@ -518,27 +518,31 @@ func (d *Daemon) init() error { /* Log expiry */ d.tasks.Add(expireLogsTask(d.State())) - /* set the initial proxy function and external auth based on config values in the DB */ + /* Setup the proxy handler, external authentication and MAAS */ macaroonEndpoint := "" maasAPIURL := "" maasAPIKey := "" maasMachine := "" + err = d.db.Transaction(func(tx *db.NodeTx) error { config, err := node.ConfigLoad(tx) if err != nil { return err } + maasMachine = config.MAASMachine() return nil }) if err != nil { return err } + err = d.cluster.Transaction(func(tx *db.ClusterTx) error { config, err := cluster.ConfigLoad(tx) if err != nil { return err } + d.proxy = shared.ProxyFromConfig( config.ProxyHTTPS(), config.ProxyHTTP(), config.ProxyIgnoreHosts(), ) @@ -549,37 +553,35 @@ func (d *Daemon) init() error { if err != nil { return err } + err = d.setupExternalAuthentication(macaroonEndpoint) if err != nil { return err } + if !d.os.MockMode { - /* Start the scheduler */ + // Start the scheduler go deviceEventListener(d.State()) + // Setup inotify watches _, err := deviceInotifyInit(d.State()) if err != nil { return err } deviceInotifyDirRescan(d.State()) - go deviceInotifyHandler(d.State()) + // Read the trusted certificates readSavedClientCAList(d) } + // Connect to MAAS err = d.setupMAASController(maasAPIURL, maasAPIKey, maasMachine) if err != nil { return err } - if !d.os.MockMode { - /* Start the scheduler */ - go deviceEventListener(d.State()) - readSavedClientCAList(d) - } - close(d.setupChan) // Run the post initialization actions diff --git a/lxd/devices.go b/lxd/devices.go index 590a3e10f..b023f3dba 100644 --- a/lxd/devices.go +++ b/lxd/devices.go @@ -817,7 +817,7 @@ func deviceUSBEvent(s *state.State, usb usbDevice) { func deviceEventListener(s *state.State) { chNetlinkCPU, chNetlinkNetwork, chUSB, err := deviceNetlinkListener() if err != nil { - logger.Errorf("scheduler: couldn't setup netlink listener") + logger.Errorf("scheduler: couldn't setup netlink listener: %v", err) return } From 6ec797482ae68c447de3f5b76671c13cbee5c530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 27 Feb 2018 17:31:38 -0500 Subject: [PATCH 2/3] shared/version: Export features in agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- shared/version/useragent.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/shared/version/useragent.go b/shared/version/useragent.go index 8e3e08965..83bf04751 100644 --- a/shared/version/useragent.go +++ b/shared/version/useragent.go @@ -9,9 +9,11 @@ import ( ) // UserAgent contains a string suitable as a user-agent -var UserAgent = getUserAgent(nil) +var UserAgent = getUserAgent() +var userAgentStorageBackends []string +var userAgentFeatures []string -func getUserAgent(storageTokens []string) string { +func getUserAgent() string { archID, err := osarch.ArchitectureId(runtime.GOARCH) if err != nil { panic(err) @@ -25,13 +27,20 @@ func getUserAgent(storageTokens []string) string { osTokens := []string{strings.Title(runtime.GOOS), arch} osTokens = append(osTokens, getPlatformVersionStrings()...) + // Initial version string agent := fmt.Sprintf("LXD %s", Version) - if len(osTokens) > 0 { - agent = fmt.Sprintf("%s (%s)", agent, strings.Join(osTokens, "; ")) + + // OS information + agent = fmt.Sprintf("%s (%s)", agent, strings.Join(osTokens, "; ")) + + // Storage information + if len(userAgentStorageBackends) > 0 { + agent = fmt.Sprintf("%s (%s)", agent, strings.Join(userAgentStorageBackends, "; ")) } - if len(storageTokens) > 0 { - agent = fmt.Sprintf("%s (%s)", agent, strings.Join(storageTokens, "; ")) + // Feature information + if len(userAgentFeatures) > 0 { + agent = fmt.Sprintf("%s (%s)", agent, strings.Join(userAgentFeatures, "; ")) } return agent @@ -39,5 +48,12 @@ func getUserAgent(storageTokens []string) string { // UserAgentStorageBackends updates the list of storage backends to include in the user-agent func UserAgentStorageBackends(backends []string) { - UserAgent = getUserAgent(backends) + userAgentStorageBackends = backends + UserAgent = getUserAgent() +} + +// UserAgentFeatures updates the list of advertised features +func UserAgentFeatures(features []string) { + userAgentFeatures = features + UserAgent = getUserAgent() } From 9d05f708db1c6a34b363dd6853bffdc193ccae97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Tue, 27 Feb 2018 17:32:04 -0500 Subject: [PATCH 3/3] Include cluster as a User-Agent feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <[email protected]> --- lxd/api_cluster.go | 13 ++++++++++++- lxd/daemon.go | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lxd/api_cluster.go b/lxd/api_cluster.go index de02463fb..ddd7de664 100644 --- a/lxd/api_cluster.go +++ b/lxd/api_cluster.go @@ -90,6 +90,7 @@ func clusterPut(d *Daemon, r *http.Request) Response { if req.ClusterAddress == "" { return clusterPutBootstrap(d, req) } + return clusterPutJoin(d, req) } @@ -105,6 +106,9 @@ func clusterPutBootstrap(d *Daemon, req api.ClusterPut) Response { return InternalError(err) } + // Add the cluster flag from the agent + version.UserAgentFeatures([]string{"cluster"}) + return OperationResponse(op) } @@ -235,9 +239,13 @@ func clusterPutJoin(d *Daemon, req api.ClusterPut) Response { if err != nil { return err } - return nil + // Add the cluster flag from the agent + version.UserAgentFeatures([]string{"cluster"}) + + return nil } + resources := map[string][]string{} resources["cluster"] = []string{} @@ -290,6 +298,9 @@ func clusterPutDisable(d *Daemon) Response { return SmartError(err) } + // Remove the cluster flag from the agent + version.UserAgentFeatures(nil) + return EmptySyncResponse } diff --git a/lxd/daemon.go b/lxd/daemon.go index 805db9679..d8ebcace7 100644 --- a/lxd/daemon.go +++ b/lxd/daemon.go @@ -491,6 +491,16 @@ func (d *Daemon) init() error { } } + // Setup the user-agent + clustered, err := cluster.Enabled(d.db) + if err != nil { + return err + } + + if clustered { + version.UserAgentFeatures([]string{"cluster"}) + } + /* Read the storage pools */ err = SetupStorageDriver(d.State(), false) if err != nil {
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
