[lxc-devel] [lxd/master] lxd: Re-introduce early check for running daemon
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Mar 13 22:20:38 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180313/d97a7acc/attachment.bin>
-------------- next part --------------
From 15d5df628e46cea0d0465ee519f673ec06480968 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 13 Mar 2018 18:20:07 -0400
Subject: [PATCH] lxd: Re-introduce early check for running daemon
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/daemon.go | 8 +++++++-
lxd/endpoints/local.go | 2 +-
lxd/endpoints/socket.go | 6 +++---
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lxd/daemon.go b/lxd/daemon.go
index 25ee1aae8..7c00809d4 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -367,8 +367,14 @@ func (d *Daemon) Init() error {
}
func (d *Daemon) init() error {
+ // Lets check if there's an existing LXD running
+ err := endpoints.CheckAlreadyRunning(d.UnixSocket())
+ if err != nil {
+ return err
+ }
+
/* Set the LVM environment */
- err := os.Setenv("LVM_SUPPRESS_FD_WARNINGS", "1")
+ err = os.Setenv("LVM_SUPPRESS_FD_WARNINGS", "1")
if err != nil {
return err
}
diff --git a/lxd/endpoints/local.go b/lxd/endpoints/local.go
index e4dd85986..c91db701e 100644
--- a/lxd/endpoints/local.go
+++ b/lxd/endpoints/local.go
@@ -9,7 +9,7 @@ import (
func localCreateListener(dir string, group string) (net.Listener, error) {
path := filepath.Join(dir, "unix.socket")
- err := socketUnixCheckAlreadyRunning(path)
+ err := CheckAlreadyRunning(path)
if err != nil {
return nil, err
}
diff --git a/lxd/endpoints/socket.go b/lxd/endpoints/socket.go
index 51ba2df46..8db63d09c 100644
--- a/lxd/endpoints/socket.go
+++ b/lxd/endpoints/socket.go
@@ -26,14 +26,14 @@ func socketUnixListen(path string) (net.Listener, error) {
}
-// Check if the socket at the given path is already bound to a running LXD
-// process, and return an error if so.
+// CheckAlreadyRunning checks if the socket at the given path is already
+// bound to a running LXD process, and return an error if so.
//
// FIXME: We should probably rather just try a regular unix socket
// connection without using the client. However this is the way
// this logic has historically behaved, so let's keep it like it
// was.
-func socketUnixCheckAlreadyRunning(path string) error {
+func CheckAlreadyRunning(path string) error {
// If there's no socket file at all, there's nothing to do.
if !shared.PathExists(path) {
return nil
More information about the lxc-devel
mailing list