diff --git a/configs/config.go b/configs/config.go
index a395854..445c282 100644
--- a/configs/config.go
+++ b/configs/config.go
@@ -9,8 +9,8 @@ import (
"github.com/cockroachdb/errors"
"github.com/dustin/go-humanize"
"github.com/mcuadros/go-defaults"
- "github.com/projecteru2/yavirt/internal/utils/notify/bison"
"github.com/projecteru2/yavirt/pkg/netx"
+ "github.com/projecteru2/yavirt/pkg/notify/bison"
"github.com/projecteru2/yavirt/pkg/utils"
"github.com/urfave/cli/v2"
diff --git a/internal/eru/agent/agent.go b/internal/eru/agent/agent.go
index c77ee75..79c2984 100644
--- a/internal/eru/agent/agent.go
+++ b/internal/eru/agent/agent.go
@@ -11,6 +11,7 @@ import (
"github.com/cockroachdb/errors"
"github.com/patrickmn/go-cache"
"github.com/projecteru2/core/log"
+ corerpc "github.com/projecteru2/core/rpc"
"github.com/projecteru2/yavirt/internal/eru/common"
"github.com/projecteru2/yavirt/internal/eru/store"
corestore "github.com/projecteru2/yavirt/internal/eru/store/core"
@@ -89,7 +90,7 @@ func NewManager(
logger.Error(ctx, err, "failed to add node")
return
}
- if e.Code() == 1031 && strings.Contains(e.Message(), "node already exists") {
+ if e.Code() == corerpc.AddNode && strings.Contains(e.Message(), "node already exists") {
logger.Infof(ctx, "node %s already exists", config.Hostname)
} else {
logger.Errorf(ctx, err, "failed to add node %s", config.Hostname)
diff --git a/internal/eru/agent/guest.go b/internal/eru/agent/guest.go
index bbc34ef..acd52a7 100644
--- a/internal/eru/agent/guest.go
+++ b/internal/eru/agent/guest.go
@@ -82,24 +82,24 @@ func (g *Guest) CheckHealth(ctx context.Context, svc service.Service, timeout ti
return true
}
- var tcpChecker []string
- var httpChecker []string
+ var tcpCheckers []string
+ var httpCheckers []string
healthCheck := g.HealthCheck
for _, port := range healthCheck.TCPPorts {
for _, ip := range g.IPs {
- tcpChecker = append(tcpChecker, fmt.Sprintf("%s:%s", ip, port))
+ tcpCheckers = append(tcpCheckers, fmt.Sprintf("%s:%s", ip, port))
}
}
if healthCheck.HTTPPort != "" {
for _, ip := range g.IPs {
- httpChecker = append(httpChecker, fmt.Sprintf("http://%s:%s%s", ip, healthCheck.HTTPPort, healthCheck.HTTPURL)) //nolint
+ httpCheckers = append(httpCheckers, fmt.Sprintf("http://%s:%s%s", ip, healthCheck.HTTPPort, healthCheck.HTTPURL)) //nolint
}
}
- f1 := utils.CheckHTTP(ctx, g.ID, httpChecker, healthCheck.HTTPCode, timeout)
- f2 := utils.CheckTCP(ctx, g.ID, tcpChecker, timeout)
+ f1 := utils.CheckHTTP(ctx, g.ID, httpCheckers, healthCheck.HTTPCode, timeout)
+ f2 := utils.CheckTCP(ctx, g.ID, tcpCheckers, timeout)
f3 := CheckCMD(ctx, svc, g.ID, healthCheck.Cmds, timeout)
return f1 && f2 && f3
}
diff --git a/internal/eru/agent/metrics.go b/internal/eru/agent/metrics.go
index da48a0c..ff816b3 100644
--- a/internal/eru/agent/metrics.go
+++ b/internal/eru/agent/metrics.go
@@ -38,17 +38,23 @@ func (mgr *Manager) GetMetricsCollector() *MetricsCollector {
func (e *MetricsCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- vmHealthyDesc
+ ch <- coreHealthyDesc
}
func (e *MetricsCollector) Collect(ch chan<- prometheus.Metric) {
+ logger := log.WithFunc("agent.MetricsCollector.Collect")
for _, v := range e.wrkStatusCache.Items() {
wrkStatus, _ := v.Object.(*types.WorkloadStatus)
+ if wrkStatus == nil {
+ logger.Warnf(context.TODO(), "[BUG] wrkStatus can't be nil here")
+ continue
+ }
if !wrkStatus.Running {
continue
}
de := vmcache.FetchDomainEntry(wrkStatus.ID)
if de == nil {
- log.WithFunc("MetricsCollector.Collect").Warnf(context.TODO(), "[eru agent] failed to get domain entry %s", wrkStatus.ID)
+ logger.Warnf(context.TODO(), "[eru agent] failed to get domain entry %s", wrkStatus.ID)
continue
}
healthy := 0
diff --git a/internal/eru/agent/node.go b/internal/eru/agent/node.go
index 7a07018..0e3aae5 100644
--- a/internal/eru/agent/node.go
+++ b/internal/eru/agent/node.go
@@ -42,6 +42,7 @@ func (m *Manager) nodeStatusReport(ctx context.Context) {
return
}
if err := m.store.CheckHealth(ctx); err != nil {
+ logger.Error(ctx, err, "failed to check health of core")
m.mCol.coreHealthy.Store(false)
} else {
m.mCol.coreHealthy.Store(true)
diff --git a/internal/eru/agent/workload.go b/internal/eru/agent/workload.go
index 3c6d947..a57b26b 100644
--- a/internal/eru/agent/workload.go
+++ b/internal/eru/agent/workload.go
@@ -139,9 +139,9 @@ func (m *Manager) checkAllWorkloads(ctx context.Context) {
return
}
- for _, workloadID := range workloadIDs {
- ID := workloadID
- _ = utils.Pool.Submit(func() { m.checkOneWorkload(ctx, ID) })
+ for idx := range workloadIDs {
+ wrkID := workloadIDs[idx]
+ _ = utils.Pool.Submit(func() { m.checkOneWorkload(ctx, wrkID) })
}
}
@@ -157,7 +157,7 @@ func (m *Manager) checkOneWorkload(ctx context.Context, ID string) bool {
m.wrkStatusCache.Set(workloadStatus.ID, workloadStatus, 0)
- if err = m.setWorkloadStatus(ctx, workloadStatus); err != nil {
+ if err := m.setWorkloadStatus(ctx, workloadStatus); err != nil {
logger.Error(ctx, err, "update workload status failed")
}
return workloadStatus.Healthy
diff --git a/internal/eru/recycle/recycle.go b/internal/eru/recycle/recycle.go
index fb8cbd7..5333321 100644
--- a/internal/eru/recycle/recycle.go
+++ b/internal/eru/recycle/recycle.go
@@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/projecteru2/core/log"
+ corerpc "github.com/projecteru2/core/rpc"
virttypes "github.com/projecteru2/libyavirt/types"
"github.com/projecteru2/yavirt/configs"
"github.com/projecteru2/yavirt/internal/eru/common"
@@ -18,7 +19,7 @@ import (
"github.com/projecteru2/yavirt/internal/eru/types"
"github.com/projecteru2/yavirt/internal/service"
"github.com/projecteru2/yavirt/internal/utils"
- "github.com/projecteru2/yavirt/internal/utils/notify/bison"
+ "github.com/projecteru2/yavirt/pkg/notify/bison"
"github.com/samber/lo"
"google.golang.org/grpc/status"
)
@@ -26,13 +27,13 @@ import (
var (
interval = 1 * time.Minute
deleteWait = 15 * time.Second
- sto store.Store
+ stor store.Store
)
func fetchWorkloads() ([]string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- wrks, err := sto.ListNodeWorkloads(ctx, configs.Hostname())
+ wrks, err := stor.ListNodeWorkloads(ctx, configs.Hostname())
if err != nil {
return nil, err
}
@@ -54,7 +55,7 @@ func deleteGuest(svc service.Service, eruID string) error {
logger.Infof(ctx, "[recycle] start to remove dangling guest %s", eruID)
// since guest deletion is a dangerous operation here,
// so we check eru again
- wrk, err := sto.GetWorkload(ctx, eruID)
+ wrk, err := stor.GetWorkload(ctx, eruID)
logger.Infof(ctx, "[recycle] guest %s, wrk: %v, err: %v", eruID, wrk, err)
if err == nil {
logger.Errorf(ctx, err, "[recycle] BUG: dangling guest %s is still in eru", eruID)
@@ -65,7 +66,7 @@ func deleteGuest(svc service.Service, eruID string) error {
if !ok {
return err
}
- if e.Code() == 1051 && strings.Contains(e.Message(), "entity count invalid") { //nolint
+ if e.Code() == corerpc.GetWorkload && strings.Contains(e.Message(), "entity count invalid") { //nolint
logger.Infof(ctx, "[recycle] start to remove local guest %s", eruID)
// When creating a guest, the core first creates the workload and then creates a record in ETCD.
// Therefore, within the time window between these two operations, we may incorrectly detect dangling guests.
@@ -85,14 +86,13 @@ func deleteGuest(svc service.Service, eruID string) error {
notifier := bison.GetService()
log.Debugf(ctx, "[recycle] notifier: %v", notifier)
if notifier != nil {
- msgList := []string{
- "delete dangling successfully ",
- "---",
- "",
- fmt.Sprintf("- **node:** %s", configs.Hostname()),
- fmt.Sprintf("- **id:** %s", eruID),
- }
- text := "\n" + strings.Join(msgList, "\n")
+ text := fmt.Sprintf(`
+delete dangling guest successfully
+---
+
+- **node:** %s
+- **id:** %s
+ `, configs.Hostname(), eruID)
if err := notifier.SendMarkdown(context.TODO(), "delete dangling guest", text); err != nil {
logger.Warnf(ctx, "[recycle] failed to send dingtalk message: %v", err)
}
@@ -104,8 +104,9 @@ func deleteGuest(svc service.Service, eruID string) error {
}
func startLoop(ctx context.Context, svc service.Service) {
- log.WithFunc("startLoop").Infof(ctx, "[recycle] starting recycle loop")
- defer log.WithFunc("startLoop").Infof(ctx, "[recycle] recycle loop stopped")
+ logger := log.WithFunc("startLoop")
+ log.WithFunc("startLoop").Info(ctx, "[recycle] starting recycle loop")
+ defer log.WithFunc("startLoop").Info(ctx, "[recycle] recycle loop stopped")
for {
select {
@@ -116,6 +117,7 @@ func startLoop(ctx context.Context, svc service.Service) {
coreIDs, err := fetchWorkloads()
if err != nil {
+ logger.Error(ctx, err, "failed to fetch workloads")
continue
}
localIDs, err := svc.GetGuestIDList(context.Background())
@@ -139,11 +141,11 @@ func startLoop(ctx context.Context, svc service.Service) {
func Setup(ctx context.Context, cfg *configs.Config, t *testing.T) (err error) {
if t == nil {
corestore.Init(ctx, &cfg.Eru)
- if sto = corestore.Get(); sto == nil {
+ if stor = corestore.Get(); stor == nil {
return common.ErrGetStoreFailed
}
} else {
- sto = storemocks.NewFakeStore()
+ stor = storemocks.NewFakeStore()
}
return nil
}
diff --git a/internal/eru/recycle/recycle_test.go b/internal/eru/recycle/recycle_test.go
index 1eb7bf2..0581ee5 100644
--- a/internal/eru/recycle/recycle_test.go
+++ b/internal/eru/recycle/recycle_test.go
@@ -8,7 +8,7 @@ import (
virttypes "github.com/projecteru2/libyavirt/types"
"github.com/projecteru2/yavirt/internal/service/mocks"
- "github.com/projecteru2/yavirt/internal/utils/notify/bison"
+ "github.com/projecteru2/yavirt/pkg/notify/bison"
"github.com/projecteru2/yavirt/pkg/test/assert"
"github.com/projecteru2/yavirt/pkg/test/mock"
@@ -27,7 +27,7 @@ func TestDeleteGuest(t *testing.T) {
assert.Nil(t, err)
svc := &mocks.Service{}
- mockSto := sto.(*storemocks.MockStore)
+ mockSto := stor.(*storemocks.MockStore)
// still in eru
mockSto.On("GetWorkload", mock.Anything, mock.Anything).Return(
@@ -61,7 +61,7 @@ func TestNormal(t *testing.T) {
svc := &mocks.Service{}
svc.On("GetGuestIDList", mock.Anything).Return([]string{"00033017009174384208170000000001", "00033017009174384208170000000002"}, nil)
- mockSto := sto.(*storemocks.MockStore)
+ mockSto := stor.(*storemocks.MockStore)
mockSto.On("ListNodeWorkloads", mock.Anything, mock.Anything).Return(
[]*types.Workload{
{
diff --git a/internal/eru/resources/core.go b/internal/eru/resources/core.go
index 0afebe2..fb4c4dd 100644
--- a/internal/eru/resources/core.go
+++ b/internal/eru/resources/core.go
@@ -17,7 +17,7 @@ import (
stotypes "github.com/projecteru2/resource-storage/storage/types"
"github.com/projecteru2/yavirt/configs"
"github.com/projecteru2/yavirt/internal/eru/types"
- "github.com/projecteru2/yavirt/internal/utils/notify/bison"
+ "github.com/projecteru2/yavirt/pkg/notify/bison"
gputypes "github.com/yuyang0/resource-gpu/gpu/types"
)
@@ -33,7 +33,7 @@ func NewCoreResourcesManager() *CoreResourcesManager {
return &CoreResourcesManager{}
}
-func (cm *CoreResourcesManager) fetchResources() {
+func (cm *CoreResourcesManager) fetchResourcesWithLock() {
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()
logger := log.WithFunc("fetchResources")
@@ -83,7 +83,7 @@ func (cm *CoreResourcesManager) GetCpumem() (ans *cpumemtypes.NodeResource) {
if ans != nil {
return
}
- cm.fetchResources()
+ cm.fetchResourcesWithLock()
cm.mu.Lock()
defer cm.mu.Unlock()
return cm.cpumem
@@ -96,7 +96,7 @@ func (cm *CoreResourcesManager) GetGPU() (ans *gputypes.NodeResource) {
if ans != nil {
return
}
- cm.fetchResources()
+ cm.fetchResourcesWithLock()
cm.mu.Lock()
defer cm.mu.Unlock()
return cm.gpu
@@ -115,7 +115,7 @@ func (cm *CoreResourcesManager) UpdateGPU(nr *gputypes.NodeResource) {
remoteNR1 := remoteNR.DeepCopy()
remoteNR1.Sub(nr)
if remoteNR1.Count() == 0 {
- logger.Debugf(ctx, "remote gpu config is consistent")
+ logger.Debug(ctx, "remote gpu config is consistent")
return
}
}
@@ -136,14 +136,14 @@ func (cm *CoreResourcesManager) UpdateGPU(nr *gputypes.NodeResource) {
notifier := bison.GetService()
if notifier != nil {
- msgList := []string{
- "update core gpu resource successfully",
- "---",
- "",
- fmt.Sprintf("- **node:** %s", configs.Hostname()),
- fmt.Sprintf("- **gpu:** %v", nr),
- }
- text := "\n" + strings.Join(msgList, "\n")
+ text := fmt.Sprintf(`
+update core gpu resource successfully
+
+---
+
+- **node:** %s
+- **gpu:** %v
+ `, configs.Hostname(), nr)
_ = notifier.SendMarkdown(ctx, "update core gpu resource successfully", text)
}
@@ -184,14 +184,13 @@ func (cm *CoreResourcesManager) UpdateCPUMem(nr *cpumemtypes.NodeResource) (err
notifier := bison.GetService()
if notifier != nil {
- msgList := []string{
- "update core cpumem resource successfully",
- "---",
- "",
- fmt.Sprintf("- **node:** %s", configs.Hostname()),
- fmt.Sprintf("- **cpumem:** %+v", localNR),
- }
- text := "\n" + strings.Join(msgList, "\n")
+ text := fmt.Sprintf(`
+update core cpumem resource successfully
+---
+
+- **node:** %s
+- **cpumem:** %+v
+ `, configs.Hostname(), localNR)
_ = notifier.SendMarkdown(ctx, "update core cpumem resource successfully", text)
}
diff --git a/internal/network/drivers/ovn/metrics.go b/internal/network/drivers/ovn/metrics.go
index 3dcc210..27dbfa6 100644
--- a/internal/network/drivers/ovn/metrics.go
+++ b/internal/network/drivers/ovn/metrics.go
@@ -9,7 +9,7 @@ import (
)
var (
- calicoHealthyDesc = prometheus.NewDesc(
+ ovnHealthyDesc = prometheus.NewDesc(
prometheus.BuildFQName("node", "ovn", "healthy"),
"ovn healthy status.",
[]string{"node"},
@@ -25,13 +25,13 @@ func (d *Driver) GetMetricsCollector() prometheus.Collector {
}
func (e *MetricsCollector) Describe(ch chan<- *prometheus.Desc) {
- ch <- calicoHealthyDesc
+ ch <- ovnHealthyDesc
}
func (e *MetricsCollector) Collect(ch chan<- prometheus.Metric) {
healthy := utils.Bool2Int(e.healthy.Load())
ch <- prometheus.MustNewConstMetric(
- calicoHealthyDesc,
+ ovnHealthyDesc,
prometheus.GaugeValue,
float64(healthy),
configs.Hostname(),
diff --git a/internal/network/drivers/vlan/metrics.go b/internal/network/drivers/vlan/metrics.go
index 38a69c2..7449a05 100644
--- a/internal/network/drivers/vlan/metrics.go
+++ b/internal/network/drivers/vlan/metrics.go
@@ -9,9 +9,9 @@ import (
)
var (
- calicoHealthyDesc = prometheus.NewDesc(
- prometheus.BuildFQName("network", "ovn", "healthy"),
- "ovn healthy status.",
+ vlanHealthyDesc = prometheus.NewDesc(
+ prometheus.BuildFQName("network", "vlan", "healthy"),
+ "vlan healthy status.",
[]string{"node"},
nil)
)
@@ -25,13 +25,13 @@ func (d *Handler) GetMetricsCollector() prometheus.Collector {
}
func (e *MetricsCollector) Describe(ch chan<- *prometheus.Desc) {
- ch <- calicoHealthyDesc
+ ch <- vlanHealthyDesc
}
func (e *MetricsCollector) Collect(ch chan<- prometheus.Metric) {
healthy := utils.Bool2Int(e.healthy.Load())
ch <- prometheus.MustNewConstMetric(
- calicoHealthyDesc,
+ vlanHealthyDesc,
prometheus.GaugeValue,
float64(healthy),
configs.Hostname(),
diff --git a/internal/rpc/grpc_app.go b/internal/rpc/grpc_app.go
index f5256b3..739e8c0 100644
--- a/internal/rpc/grpc_app.go
+++ b/internal/rpc/grpc_app.go
@@ -79,7 +79,7 @@ func (y *GRPCYavirtd) GetGuest(ctx context.Context, opts *pb.GetGuestOptions) (*
// GetGuestIDList gets all local vms' domain names regardless of their metadata validility.
func (y *GRPCYavirtd) GetGuestIDList(ctx context.Context, _ *pb.GetGuestIDListOptions) (*pb.GetGuestIDListMessage, error) {
- log.Infof(ctx, "[grpcserver] get guest id list")
+ log.Info(ctx, "[grpcserver] get guest id list")
ids, err := y.service.GetGuestIDList(ctx)
if err != nil {
return nil, errors.Wrap(err, "")
@@ -94,8 +94,8 @@ func (y *GRPCYavirtd) GetGuestIDList(ctx context.Context, _ *pb.GetGuestIDListOp
func (y *GRPCYavirtd) Events(_ *pb.EventsOptions, server pb.YavirtdRPC_EventsServer) error {
ctx := server.Context()
- log.Infof(ctx, "[grpcserver] events method calling")
- defer log.Infof(ctx, "[grpcserver] events method completed")
+ log.Info(ctx, "[grpcserver] events method calling")
+ defer log.Info(ctx, "[grpcserver] events method completed")
watcher, err := y.service.WatchGuestEvents(ctx)
if err != nil {
@@ -107,7 +107,7 @@ func (y *GRPCYavirtd) Events(_ *pb.EventsOptions, server pb.YavirtdRPC_EventsSer
wg.Add(1)
go func() {
- defer log.Infof(ctx, "[grpcserver] events goroutine has done")
+ defer log.Info(ctx, "[grpcserver] events goroutine has done")
defer wg.Done()
defer watcher.Stop()
@@ -121,11 +121,11 @@ func (y *GRPCYavirtd) Events(_ *pb.EventsOptions, server pb.YavirtdRPC_EventsSer
case <-watcher.Done():
// The watcher already has been stopped.
- log.Infof(ctx, "[grpcserver] watcher has done")
+ log.Info(ctx, "[grpcserver] watcher has done")
return
case <-ctx.Done():
- log.Infof(ctx, "[grpcserver] ctx done")
+ log.Info(ctx, "[grpcserver] ctx done")
return
}
}
@@ -227,7 +227,7 @@ func (y *GRPCYavirtd) ControlGuest(ctx context.Context, opts *pb.ControlGuestOpt
// AttachGuest .
func (y *GRPCYavirtd) AttachGuest(server pb.YavirtdRPC_AttachGuestServer) (err error) {
ctx := server.Context()
- defer log.Infof(ctx, "[grpcserver] attach guest complete")
+ defer log.Info(ctx, "[grpcserver] attach guest complete")
opts, err := server.Recv()
if err != nil {
return
@@ -264,7 +264,7 @@ func (y *GRPCYavirtd) ExecuteGuest(ctx context.Context, opts *pb.ExecuteGuestOpt
}
func (y *GRPCYavirtd) ExecExitCode(ctx context.Context, opts *pb.ExecExitCodeOptions) (msg *pb.ExecExitCodeMessage, err error) {
- log.Infof(ctx, "[grpcserver] get exit code start")
+ log.Infof(ctx, "[grpcserver] get exit code start %q", opts)
defer log.Infof(ctx, "[grpcserver] get exit code done")
req := types.GuestReq{ID: opts.Id}
@@ -278,7 +278,7 @@ func (y *GRPCYavirtd) ExecExitCode(ctx context.Context, opts *pb.ExecExitCodeOpt
// ConnectNetwork .
func (y *GRPCYavirtd) ConnectNetwork(ctx context.Context, opts *pb.ConnectNetworkOptions) (*pb.ConnectNetworkMessage, error) {
- log.Infof(ctx, "[grpcserver] connect network start")
+ log.Infof(ctx, "[grpcserver] connect network start %q", opts)
req := types.ConnectNetworkReq{
Network: opts.Network,
diff --git a/internal/service/boar/boar.go b/internal/service/boar/boar.go
index f650597..35783f1 100644
--- a/internal/service/boar/boar.go
+++ b/internal/service/boar/boar.go
@@ -24,11 +24,11 @@ import (
networkFactory "github.com/projecteru2/yavirt/internal/network/factory"
intertypes "github.com/projecteru2/yavirt/internal/types"
interutils "github.com/projecteru2/yavirt/internal/utils"
- "github.com/projecteru2/yavirt/internal/utils/notify/bison"
"github.com/projecteru2/yavirt/internal/ver"
"github.com/projecteru2/yavirt/internal/virt/guest"
"github.com/projecteru2/yavirt/internal/vmcache"
"github.com/projecteru2/yavirt/pkg/idgen"
+ "github.com/projecteru2/yavirt/pkg/notify/bison"
"github.com/projecteru2/yavirt/pkg/store"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
diff --git a/internal/service/boar/create.go b/internal/service/boar/create.go
index e80ba22..e7430d7 100644
--- a/internal/service/boar/create.go
+++ b/internal/service/boar/create.go
@@ -91,21 +91,21 @@ func (svc *Boar) Create(ctx context.Context, opts intertypes.GuestCreateOption,
}
func (svc *Boar) create(ctx context.Context, vg *guest.Guest) (err error) {
- logger := log.WithFunc("Boar.create")
+ logger := log.WithFunc("Boar.create").WithField("guest", vg.ID)
logger.Debugf(ctx, "starting to cache image")
if err := vg.CacheImage(&svc.imageMutex); err != nil {
return errors.Wrap(err, "")
}
- logger.Debugf(ctx, "creating network")
+ logger.Debug(ctx, "creating network")
if err = vg.CreateNetwork(ctx); err != nil {
return err
}
- logger.Debugf(ctx, "preparing volumes")
+ logger.Debug(ctx, "preparing volumes")
if err = vg.PrepareVolumesForCreate(ctx); err != nil {
return err
}
- logger.Debugf(ctx, "defining guest")
+ logger.Debug(ctx, "defining guest")
if err = vg.DefineGuestForCreate(ctx); err != nil {
return errors.Wrap(err, "")
}
diff --git a/internal/vmcache/domain.go b/internal/vmcache/domain.go
index a77bd22..44f8788 100644
--- a/internal/vmcache/domain.go
+++ b/internal/vmcache/domain.go
@@ -334,7 +334,7 @@ func (vc *VMCache) updateStats(ctx context.Context) {
flags := libvirt.ConnectGetAllDomainsStatsRunning
statList, err := l.ConnectGetAllDomainStats(nil, 0, flags)
if err != nil {
- logger.Errorf(ctx, err, "failed to get all domain stats")
+ logger.Error(ctx, err, "failed to get all domain stats")
continue
}
for _, stats := range statList {
diff --git a/internal/utils/notify/bison/bison.go b/pkg/notify/bison/bison.go
similarity index 85%
rename from internal/utils/notify/bison/bison.go
rename to pkg/notify/bison/bison.go
index 221c992..d742781 100644
--- a/internal/utils/notify/bison/bison.go
+++ b/pkg/notify/bison/bison.go
@@ -5,10 +5,10 @@ import (
"testing"
"github.com/alphadose/haxmap"
- "github.com/projecteru2/yavirt/internal/utils/notify"
- "github.com/projecteru2/yavirt/internal/utils/notify/services/all"
- "github.com/projecteru2/yavirt/internal/utils/notify/services/dingding"
- "github.com/projecteru2/yavirt/internal/utils/notify/services/mail"
+ "github.com/projecteru2/yavirt/pkg/notify"
+ "github.com/projecteru2/yavirt/pkg/notify/services/all"
+ "github.com/projecteru2/yavirt/pkg/notify/services/dingding"
+ "github.com/projecteru2/yavirt/pkg/notify/services/mail"
)
var bs *Manager
diff --git a/internal/utils/notify/notify.go b/pkg/notify/notify.go
similarity index 100%
rename from internal/utils/notify/notify.go
rename to pkg/notify/notify.go
diff --git a/internal/utils/notify/services/all/all.go b/pkg/notify/services/all/all.go
similarity index 93%
rename from internal/utils/notify/services/all/all.go
rename to pkg/notify/services/all/all.go
index eb86a07..a461aa5 100644
--- a/internal/utils/notify/services/all/all.go
+++ b/pkg/notify/services/all/all.go
@@ -4,7 +4,7 @@ import (
"context"
"github.com/cockroachdb/errors"
- "github.com/projecteru2/yavirt/internal/utils/notify"
+ "github.com/projecteru2/yavirt/pkg/notify"
)
type Config struct {
diff --git a/internal/utils/notify/services/dingding/.gitignore b/pkg/notify/services/dingding/.gitignore
similarity index 100%
rename from internal/utils/notify/services/dingding/.gitignore
rename to pkg/notify/services/dingding/.gitignore
diff --git a/internal/utils/notify/services/dingding/dingding.go b/pkg/notify/services/dingding/dingding.go
similarity index 100%
rename from internal/utils/notify/services/dingding/dingding.go
rename to pkg/notify/services/dingding/dingding.go
diff --git a/internal/utils/notify/services/mail/.gitignore b/pkg/notify/services/mail/.gitignore
similarity index 100%
rename from internal/utils/notify/services/mail/.gitignore
rename to pkg/notify/services/mail/.gitignore
diff --git a/internal/utils/notify/services/mail/mail.go b/pkg/notify/services/mail/mail.go
similarity index 100%
rename from internal/utils/notify/services/mail/mail.go
rename to pkg/notify/services/mail/mail.go