From 69cd7d7929958bd9dad5a246fcccbff2649d5183 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 17 Sep 2024 16:41:41 +0200 Subject: [PATCH 1/4] Use kairos logger Signed-off-by: Itxaka --- go.mod | 10 ++--- go.sum | 4 ++ internal/provider/bootstrap.go | 79 +++++++++++++--------------------- 3 files changed, 39 insertions(+), 54 deletions(-) diff --git a/go.mod b/go.mod index b5412717..bede4128 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/kairos-io/provider-kairos/v2 -go 1.22.5 +go 1.23.1 replace github.com/elastic/gosigar => github.com/mudler/gosigar v0.14.3-0.20220502202347-34be910bdaaf @@ -10,7 +10,7 @@ require ( github.com/ipfs/go-log/v2 v2.5.1 github.com/kairos-io/go-nodepair v0.2.0 github.com/kairos-io/kairos-agent/v2 v2.14.0 - github.com/kairos-io/kairos-sdk v0.4.2 + github.com/kairos-io/kairos-sdk v0.4.4 github.com/mudler/edgevpn v0.28.3 github.com/mudler/go-pluggable v0.0.0-20230126220627-7710299a0ae5 github.com/mudler/go-processmanager v0.0.0-20240820160718-8b802d3ecf82 @@ -49,7 +49,7 @@ require ( github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/containerd/console v1.0.4-0.20230706203907-8f6c4e4faef5 // indirect - github.com/containerd/containerd v1.7.21 // indirect + github.com/containerd/containerd v1.7.22 // indirect github.com/containerd/continuity v0.4.2 // indirect github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/log v0.1.0 // indirect @@ -68,7 +68,7 @@ require ( github.com/djherbis/times v1.6.0 // indirect github.com/docker/cli v27.1.1+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v27.2.0+incompatible // indirect + github.com/docker/docker v27.2.1+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -296,7 +296,7 @@ require ( golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect golang.org/x/image v0.18.0 // indirect - golang.org/x/mod v0.20.0 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.29.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.25.0 // indirect diff --git a/go.sum b/go.sum index e9e9f344..1618fa39 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,7 @@ github.com/containerd/containerd v1.7.20 h1:Sl6jQYk3TRavaU83h66QMbI2Nqg9Jm6qzwX5 github.com/containerd/containerd v1.7.20/go.mod h1:52GsS5CwquuqPuLncsXwG0t2CiUce+KsNHJZQJvAgR0= github.com/containerd/containerd v1.7.21 h1:USGXRK1eOC/SX0L195YgxTHb0a00anxajOzgfN0qrCA= github.com/containerd/containerd v1.7.21/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= +github.com/containerd/containerd v1.7.22/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= @@ -180,6 +181,7 @@ github.com/docker/docker v27.1.2+incompatible h1:AhGzR1xaQIy53qCkxARaFluI00WPGtX github.com/docker/docker v27.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4= github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -445,6 +447,7 @@ github.com/kairos-io/kairos-sdk v0.4.1 h1:WF+X30URojMxV7AlzVj0uejvPWG4zq1WNga0sw github.com/kairos-io/kairos-sdk v0.4.1/go.mod h1:lgQAYkh0aWIZg4/CQcC+OPQp95ONs2PzkMIcAq8w6OY= github.com/kairos-io/kairos-sdk v0.4.2 h1:tq0a6R9qSotatFt20q/+oIHJSN+XTQWji4XgHk5Vvlw= github.com/kairos-io/kairos-sdk v0.4.2/go.mod h1:1x8VaVt1ppXxQUlNyDRksoDglR423hxfEtjx6qWDO7w= +github.com/kairos-io/kairos-sdk v0.4.4/go.mod h1:OIJYihhuiUOeBXHYj9V3R381SAgc/EaKrFepcBxGroM= github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237 h1:YOp8St+CM/AQ9Vp4XYm4272E77MptJDHkwypQHIRl9Q= github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237/go.mod h1:e7qQlOY68wOz4b82D7n+DdaptZAi+SHW0+yKiWZzEYE= github.com/kendru/darwin/go/depgraph v0.0.0-20221105232959-877d6a81060c h1:eKb4PqwAMhlqwXw0W3atpKaYaPGlXE/Fwh+xpCEYaPk= @@ -1154,6 +1157,7 @@ golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/internal/provider/bootstrap.go b/internal/provider/bootstrap.go index de30227e..25fc7bfe 100644 --- a/internal/provider/bootstrap.go +++ b/internal/provider/bootstrap.go @@ -6,18 +6,16 @@ import ( "fmt" "strings" - logging "github.com/ipfs/go-log/v2" - edgeVPNClient "github.com/mudler/edgevpn/api/client" - "go.uber.org/zap" - "github.com/kairos-io/kairos-sdk/bus" "github.com/kairos-io/kairos-sdk/machine" "github.com/kairos-io/kairos-sdk/machine/openrc" "github.com/kairos-io/kairos-sdk/machine/systemd" + "github.com/kairos-io/kairos-sdk/types" "github.com/kairos-io/kairos-sdk/utils" providerConfig "github.com/kairos-io/provider-kairos/v2/internal/provider/config" "github.com/kairos-io/provider-kairos/v2/internal/role" p2p "github.com/kairos-io/provider-kairos/v2/internal/role/p2p" + edgeVPNClient "github.com/mudler/edgevpn/api/client" "github.com/kairos-io/provider-kairos/v2/internal/services" @@ -34,23 +32,23 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { } c := &config.Config{} - providerConfig := &providerConfig.Config{} + prvConfig := &providerConfig.Config{} err = config.FromString(cfg.Config, c) if err != nil { return ErrorEvent("Failed reading JSON input: %s input '%s'", err.Error(), cfg.Config) } - err = config.FromString(cfg.Config, providerConfig) + err = config.FromString(cfg.Config, prvConfig) if err != nil { return ErrorEvent("Failed reading JSON input: %s input '%s'", err.Error(), cfg.Config) } // TODO: this belong to a systemd service that is started instead - p2pBlockDefined := providerConfig.P2P != nil - tokenNotDefined := ((p2pBlockDefined && providerConfig.P2P.NetworkToken == "") || !p2pBlockDefined) - skipAuto := (p2pBlockDefined && !providerConfig.P2P.Auto.IsEnabled()) + p2pBlockDefined := prvConfig.P2P != nil + tokenNotDefined := (p2pBlockDefined && prvConfig.P2P.NetworkToken == "") || !p2pBlockDefined + skipAuto := p2pBlockDefined && !prvConfig.P2P.Auto.IsEnabled() - if providerConfig.P2P == nil && !providerConfig.K3s.Enabled && !providerConfig.K3sAgent.Enabled { + if prvConfig.P2P == nil && !prvConfig.K3s.Enabled && !prvConfig.K3sAgent.Enabled { return pluggable.EventResponse{State: fmt.Sprintf("no kairos or k3s configuration. nothing to do: %s", cfg.Config)} } @@ -59,35 +57,18 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { logLevel := "debug" - if p2pBlockDefined && providerConfig.P2P.LogLevel != "" { - logLevel = providerConfig.P2P.LogLevel - } - - lvl, err := logging.LevelFromString(logLevel) - if err != nil { - return ErrorEvent("Failed setup logger: %s", err.Error()) + if p2pBlockDefined && prvConfig.P2P.LogLevel != "" { + logLevel = prvConfig.P2P.LogLevel } - // TODO: Fixup Logging to file - loggerCfg := zap.NewProductionConfig() - loggerCfg.OutputPaths = []string{ - cfg.Logfile, - } - logger, err := loggerCfg.Build() - if err != nil { - return ErrorEvent("Failed setup logger: %s", err.Error()) - } - - logging.SetAllLoggers(lvl) - - log := &logging.ZapEventLogger{SugaredLogger: *logger.Sugar()} + logger := types.NewKairosLogger("agent", logLevel, false) // Do onetimebootstrap if K3s or K3s-agent are enabled. // Those blocks are not required to be enabled in case of a kairos // full automated setup. Otherwise, they must be explicitly enabled. - if (tokenNotDefined && (providerConfig.K3s.Enabled || providerConfig.K3sAgent.Enabled)) || skipAuto { - err := oneTimeBootstrap(log, providerConfig, func() error { - return SetupVPN(services.EdgeVPNDefaultInstance, cfg.APIAddress, "/", true, providerConfig) + if (tokenNotDefined && (prvConfig.K3s.Enabled || prvConfig.K3sAgent.Enabled)) || skipAuto { + err := oneTimeBootstrap(logger, prvConfig, func() error { + return SetupVPN(services.EdgeVPNDefaultInstance, cfg.APIAddress, "/", true, prvConfig) }) if err != nil { return ErrorEvent("Failed setup: %s", err.Error()) @@ -100,22 +81,22 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { } // We might still want a VPN, but not to route traffic into - if providerConfig.P2P.VPNNeedsCreation() { + if prvConfig.P2P.VPNNeedsCreation() { logger.Info("Configuring VPN") - if err := SetupVPN(services.EdgeVPNDefaultInstance, cfg.APIAddress, "/", true, providerConfig); err != nil { + if err := SetupVPN(services.EdgeVPNDefaultInstance, cfg.APIAddress, "/", true, prvConfig); err != nil { return ErrorEvent("Failed setup VPN: %s", err.Error()) } } else { // We need at least the API to co-ordinate logger.Info("Configuring API") - if err := SetupAPI(cfg.APIAddress, "/", true, providerConfig); err != nil { + if err := SetupAPI(cfg.APIAddress, "/", true, prvConfig); err != nil { return ErrorEvent("Failed setup VPN: %s", err.Error()) } } networkID := "kairos" - if p2pBlockDefined && providerConfig.P2P.NetworkID != "" { - networkID = providerConfig.P2P.NetworkID + if p2pBlockDefined && prvConfig.P2P.NetworkID != "" { + networkID = prvConfig.P2P.NetworkID } cc := service.NewClient( @@ -123,40 +104,40 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { edgeVPNClient.NewClient(edgeVPNClient.WithHost(cfg.APIAddress))) nodeOpts := []service.Option{ - service.WithMinNodes(providerConfig.P2P.MinimumNodes), - service.WithLogger(log), + service.WithMinNodes(prvConfig.P2P.MinimumNodes), + service.WithLogger(logger), service.WithClient(cc), service.WithUUID(machine.UUID()), service.WithStateDir("/usr/local/.kairos/state"), - service.WithNetworkToken(providerConfig.P2P.NetworkToken), + service.WithNetworkToken(prvConfig.P2P.NetworkToken), service.WithPersistentRoles("auto"), service.WithRoles( service.RoleKey{ Role: "master", - RoleHandler: p2p.Master(c, providerConfig, false, false, "master"), + RoleHandler: p2p.Master(c, prvConfig, false, false, "master"), }, service.RoleKey{ Role: "master/clusterinit", - RoleHandler: p2p.Master(c, providerConfig, true, true, "master/clusterinit"), + RoleHandler: p2p.Master(c, prvConfig, true, true, "master/clusterinit"), }, service.RoleKey{ Role: "master/ha", - RoleHandler: p2p.Master(c, providerConfig, false, true, "master/ha"), + RoleHandler: p2p.Master(c, prvConfig, false, true, "master/ha"), }, service.RoleKey{ Role: "worker", - RoleHandler: p2p.Worker(c, providerConfig), + RoleHandler: p2p.Worker(c, prvConfig), }, service.RoleKey{ Role: "auto", - RoleHandler: role.Auto(c, providerConfig), + RoleHandler: role.Auto(c, prvConfig), }, ), } // Optionally set up a specific node role if the user has defined so - if providerConfig.P2P.Role != "" { - nodeOpts = append(nodeOpts, service.WithDefaultRoles(providerConfig.P2P.Role)) + if prvConfig.P2P.Role != "" { + nodeOpts = append(nodeOpts, service.WithDefaultRoles(prvConfig.P2P.Role)) } k, err := service.NewNode(nodeOpts...) @@ -175,7 +156,7 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { } } -func oneTimeBootstrap(l logging.StandardLogger, c *providerConfig.Config, vpnSetupFN func() error) error { +func oneTimeBootstrap(l types.KairosLogger, c *providerConfig.Config, vpnSetupFN func() error) error { var err error if role.SentinelExist() { l.Info("Sentinel exists, nothing to do. exiting.") From 34249b177c6a3f2456af74285f89c6d07ee201db Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 17 Sep 2024 16:41:41 +0200 Subject: [PATCH 2/4] Use kairos logger Signed-off-by: Itxaka --- Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Earthfile b/Earthfile index f6225ef0..48b40c17 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.6 # renovate: datasource=docker depName=golang -ARG GO_VERSION=1.22 +ARG GO_VERSION=1.23 ARG TARGETARCH ARG CGO_ENABLED=0 From 3fca1af331c00898ab72e127c468c09e61ae8ac3 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 17 Sep 2024 16:46:13 +0200 Subject: [PATCH 3/4] Drop uneeded logging test No need to test if we log to file Signed-off-by: Itxaka --- go.sum | 4 +++ internal/provider/bootstrap_test.go | 54 ----------------------------- 2 files changed, 4 insertions(+), 54 deletions(-) delete mode 100644 internal/provider/bootstrap_test.go diff --git a/go.sum b/go.sum index 1618fa39..ee0b175f 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,7 @@ github.com/containerd/containerd v1.7.20 h1:Sl6jQYk3TRavaU83h66QMbI2Nqg9Jm6qzwX5 github.com/containerd/containerd v1.7.20/go.mod h1:52GsS5CwquuqPuLncsXwG0t2CiUce+KsNHJZQJvAgR0= github.com/containerd/containerd v1.7.21 h1:USGXRK1eOC/SX0L195YgxTHb0a00anxajOzgfN0qrCA= github.com/containerd/containerd v1.7.21/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= +github.com/containerd/containerd v1.7.22 h1:nZuNnNRA6T6jB975rx2RRNqqH2k6ELYKDZfqTHqwyy0= github.com/containerd/containerd v1.7.22/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= @@ -181,6 +182,7 @@ github.com/docker/docker v27.1.2+incompatible h1:AhGzR1xaQIy53qCkxARaFluI00WPGtX github.com/docker/docker v27.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4= github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI= github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= @@ -447,6 +449,7 @@ github.com/kairos-io/kairos-sdk v0.4.1 h1:WF+X30URojMxV7AlzVj0uejvPWG4zq1WNga0sw github.com/kairos-io/kairos-sdk v0.4.1/go.mod h1:lgQAYkh0aWIZg4/CQcC+OPQp95ONs2PzkMIcAq8w6OY= github.com/kairos-io/kairos-sdk v0.4.2 h1:tq0a6R9qSotatFt20q/+oIHJSN+XTQWji4XgHk5Vvlw= github.com/kairos-io/kairos-sdk v0.4.2/go.mod h1:1x8VaVt1ppXxQUlNyDRksoDglR423hxfEtjx6qWDO7w= +github.com/kairos-io/kairos-sdk v0.4.4 h1:FolUGqpdTnYYdLwFEOND97QEp2H/htVjW7pHUOmtxNI= github.com/kairos-io/kairos-sdk v0.4.4/go.mod h1:OIJYihhuiUOeBXHYj9V3R381SAgc/EaKrFepcBxGroM= github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237 h1:YOp8St+CM/AQ9Vp4XYm4272E77MptJDHkwypQHIRl9Q= github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237/go.mod h1:e7qQlOY68wOz4b82D7n+DdaptZAi+SHW0+yKiWZzEYE= @@ -1157,6 +1160,7 @@ golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/internal/provider/bootstrap_test.go b/internal/provider/bootstrap_test.go deleted file mode 100644 index 9c2c0721..00000000 --- a/internal/provider/bootstrap_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package provider_test - -import ( - "encoding/json" - "io/ioutil" - "os" - - "github.com/kairos-io/kairos-sdk/bus" - - . "github.com/kairos-io/provider-kairos/v2/internal/provider" - providerConfig "github.com/kairos-io/provider-kairos/v2/internal/provider/config" - "github.com/mudler/go-pluggable" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "gopkg.in/yaml.v3" -) - -var _ = Describe("Bootstrap provider", func() { - Context("logging", func() { - e := &pluggable.Event{} - - BeforeEach(func() { - e = &pluggable.Event{} - }) - - It("logs to file", func() { - f, err := ioutil.TempFile(os.TempDir(), "tests") - Expect(err).ToNot(HaveOccurred()) - defer os.RemoveAll(f.Name()) - - cfg := &providerConfig.Config{ - P2P: &providerConfig.P2P{ - NetworkToken: "foo", - }, - } - dat, err := yaml.Marshal(cfg) - Expect(err).ToNot(HaveOccurred()) - payload := &bus.BootstrapPayload{Logfile: f.Name(), Config: string(dat)} - - dat, err = json.Marshal(payload) - Expect(err).ToNot(HaveOccurred()) - - e.Data = string(dat) - resp := Bootstrap(e) - dat, _ = json.Marshal(resp) - Expect(resp.Errored()).To(BeTrue(), string(dat)) - - data, err := ioutil.ReadFile(f.Name()) - Expect(err).ToNot(HaveOccurred()) - - Expect(string(data)).Should(ContainSubstring("Configuring VPN")) - }) - }) -}) From a33df8f38d9c4dab2989579acfe1436b569f42bd Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 18 Sep 2024 10:31:24 +0200 Subject: [PATCH 4/4] Use proper naming for log Signed-off-by: Itxaka --- internal/provider/bootstrap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/bootstrap.go b/internal/provider/bootstrap.go index 25fc7bfe..cdf1e085 100644 --- a/internal/provider/bootstrap.go +++ b/internal/provider/bootstrap.go @@ -61,7 +61,7 @@ func Bootstrap(e *pluggable.Event) pluggable.EventResponse { logLevel = prvConfig.P2P.LogLevel } - logger := types.NewKairosLogger("agent", logLevel, false) + logger := types.NewKairosLogger("provider", logLevel, false) // Do onetimebootstrap if K3s or K3s-agent are enabled. // Those blocks are not required to be enabled in case of a kairos