From 7627c13c872ded2712e53234846da0cf47755d2e Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Thu, 19 Sep 2024 21:05:52 +0400 Subject: [PATCH 1/3] add detailed resource log --- harmony/harmonytask/task_type_handler.go | 7 ++++--- harmony/resources/resources.go | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/harmony/harmonytask/task_type_handler.go b/harmony/harmonytask/task_type_handler.go index 9e93fd613..b58e8600d 100644 --- a/harmony/harmonytask/task_type_handler.go +++ b/harmony/harmonytask/task_type_handler.go @@ -11,6 +11,7 @@ import ( logging "github.com/ipfs/go-log/v2" "go.opencensus.io/stats" "go.opencensus.io/tag" + "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" @@ -336,13 +337,13 @@ func (h *taskTypeHandler) AssertMachineHasCapacity() error { } if r.Cpu-h.Cost.Cpu < 0 { - return errors.New("Did not accept " + h.Name + " task: out of cpu") + return xerrors.Errorf("Did not accept %s task: out of cpu: required %d available %d)", h.Name, h.Cost.Cpu, r.Cpu) } if h.Cost.Ram > r.Ram { - return errors.New("Did not accept " + h.Name + " task: out of RAM") + return xerrors.Errorf("Did not accept %s task: out of RAM: required %d available %d)", h.Name, h.Cost.Ram, r.Ram) } if r.Gpu-h.Cost.Gpu < 0 { - return errors.New("Did not accept " + h.Name + " task: out of available GPU") + return xerrors.Errorf("Did not accept %s task: out of available GPU: required %f available %f)", h.Name, h.Cost.Gpu, r.Gpu) } if h.TaskTypeDetails.Cost.Storage != nil { diff --git a/harmony/resources/resources.go b/harmony/resources/resources.go index 48d524ddb..98ba6192e 100644 --- a/harmony/resources/resources.go +++ b/harmony/resources/resources.go @@ -98,6 +98,8 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) { } }() + logger.Infow("Node registered the following resources", "CPU", reg.Cpu, "Memory", reg.Ram, "GPU", reg.Gpu) + return ®, nil } From 0df6eec39168ceca7a75df122b2aa88c9a443269 Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Fri, 20 Sep 2024 19:57:31 +0400 Subject: [PATCH 2/3] Add more logging for resources --- harmony/harmonytask/harmonytask.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/harmony/harmonytask/harmonytask.go b/harmony/harmonytask/harmonytask.go index e59b79ca3..9bdbf3adb 100644 --- a/harmony/harmonytask/harmonytask.go +++ b/harmony/harmonytask/harmonytask.go @@ -428,12 +428,15 @@ func (e *TaskEngine) pollerTryAllWork() bool { // ResourcesAvailable determines what resources are still unassigned. func (e *TaskEngine) ResourcesAvailable() resources.Resources { tmp := e.reg.Resources + llog := log.With("Resource availability Check") for _, t := range e.handlers { ct := t.Max.ActiveThis() tmp.Cpu -= ct * t.Cost.Cpu tmp.Gpu -= float64(ct) * t.Cost.Gpu tmp.Ram -= uint64(ct) * t.Cost.Ram + llog.Infow("Per task type", "Name", t.Name, "Count", ct, "CPU", ct*t.Cost.Cpu, "RAM", uint64(ct)*t.Cost.Ram, "GPU", float64(ct)*t.Cost.Gpu) } + llog.Infow("Total", "CPU", tmp.Cpu, "RAM", tmp.Ram, "GPU", tmp.Gpu) return tmp } From ed8a6532cbf8f4194130240b634184f1c39dcd77 Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Fri, 4 Oct 2024 17:38:12 +0400 Subject: [PATCH 3/3] use a separate logger with debug --- harmony/harmonytask/harmonytask.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/harmony/harmonytask/harmonytask.go b/harmony/harmonytask/harmonytask.go index 9bdbf3adb..f14035bb0 100644 --- a/harmony/harmonytask/harmonytask.go +++ b/harmony/harmonytask/harmonytask.go @@ -7,6 +7,7 @@ import ( "sync/atomic" "time" + logging "github.com/ipfs/go-log/v2" "github.com/samber/lo" "go.opencensus.io/stats" "go.opencensus.io/tag" @@ -425,18 +426,20 @@ func (e *TaskEngine) pollerTryAllWork() bool { return false } +var rlog = logging.Logger("harmony-res") + // ResourcesAvailable determines what resources are still unassigned. func (e *TaskEngine) ResourcesAvailable() resources.Resources { tmp := e.reg.Resources - llog := log.With("Resource availability Check") + llog := rlog.With("Resource availability Check") for _, t := range e.handlers { ct := t.Max.ActiveThis() tmp.Cpu -= ct * t.Cost.Cpu tmp.Gpu -= float64(ct) * t.Cost.Gpu tmp.Ram -= uint64(ct) * t.Cost.Ram - llog.Infow("Per task type", "Name", t.Name, "Count", ct, "CPU", ct*t.Cost.Cpu, "RAM", uint64(ct)*t.Cost.Ram, "GPU", float64(ct)*t.Cost.Gpu) + llog.Debugw("Per task type", "Name", t.Name, "Count", ct, "CPU", ct*t.Cost.Cpu, "RAM", uint64(ct)*t.Cost.Ram, "GPU", float64(ct)*t.Cost.Gpu) } - llog.Infow("Total", "CPU", tmp.Cpu, "RAM", tmp.Ram, "GPU", tmp.Gpu) + llog.Debugw("Total", "CPU", tmp.Cpu, "RAM", tmp.Ram, "GPU", tmp.Gpu) return tmp }