From da4d1aced4737efb3105d811a8215745f891185e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 21 Oct 2024 11:57:16 -0400 Subject: [PATCH] incusd/cluster: Actually use YAML for resources cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- cmd/incusd/daemon.go | 4 ++-- internal/server/instance/drivers/util.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/incusd/daemon.go b/cmd/incusd/daemon.go index 63642a02842..6b754295c7a 100644 --- a/cmd/incusd/daemon.go +++ b/cmd/incusd/daemon.go @@ -5,7 +5,6 @@ import ( "context" "crypto/x509" "database/sql" - "encoding/json" "errors" "fmt" "io" @@ -26,6 +25,7 @@ import ( "github.com/gorilla/mux" liblxc "github.com/lxc/go-lxc" "golang.org/x/sys/unix" + yaml "gopkg.in/yaml.v2" internalIO "github.com/lxc/incus/v6/internal/io" "github.com/lxc/incus/v6/internal/linux" @@ -2405,7 +2405,7 @@ func (d *Daemon) heartbeatHandler(w http.ResponseWriter, r *http.Request, isLead } // Write to cache. - data, err := json.Marshal(resources) + data, err := yaml.Marshal(resources) if err != nil { return } diff --git a/internal/server/instance/drivers/util.go b/internal/server/instance/drivers/util.go index c588e2809f4..93f71d6c654 100644 --- a/internal/server/instance/drivers/util.go +++ b/internal/server/instance/drivers/util.go @@ -2,7 +2,6 @@ package drivers import ( "context" - "encoding/json" "errors" "fmt" "io/fs" @@ -11,6 +10,8 @@ import ( "strconv" "strings" + yaml "gopkg.in/yaml.v2" + "github.com/lxc/incus/v6/internal/linux" "github.com/lxc/incus/v6/internal/server/db" "github.com/lxc/incus/v6/internal/server/instance/instancetype" @@ -56,7 +57,7 @@ func GetClusterCPUFlags(ctx context.Context, s *state.State, servers []string, a } res := api.Resources{} - err = json.Unmarshal(data, &res) + err = yaml.Unmarshal(data, &res) if err != nil { return nil, err }