From c43137f376e63d0c5f8225a8059f2527e2aeb187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 17 Apr 2024 10:47:48 -0400 Subject: [PATCH] lxd/daemon: Use hostname as default instance property on standalone systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/lxc/incus/issues/762 Signed-off-by: Stéphane Graber (cherry picked from commit f7acfd818d3538c9908438bb92e64ec669dbd165) Signed-off-by: Simon Deziel License: Apache-2.0 --- lxd/daemon.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lxd/daemon.go b/lxd/daemon.go index 4dc16556ea6f..7be5e6537554 100644 --- a/lxd/daemon.go +++ b/lxd/daemon.go @@ -812,7 +812,16 @@ func (d *Daemon) setupLoki(URL string, cert string, key string, caCert string, i // Figure out the instance name. if instanceName == "" { - instanceName = d.serverName + if d.serverClustered { + instanceName = d.serverName + } else { + hostname, err := os.Hostname() + if err != nil { + return err + } + + instanceName = hostname + } } // Start a new client.