From c6254f1ebb98733d971d0e65a677809d1bdfff2a Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 19 Jul 2017 11:34:18 +0200 Subject: [PATCH] Warning instead of Error for going on negative on account, defer file close for cpu_profiling --- cmd/cgr-engine/cgr-engine.go | 3 +-- engine/account.go | 2 +- engine/balances.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 3118a9166..1625f2ba8 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -22,7 +22,6 @@ import ( "fmt" "log" "log/syslog" - // _ "net/http/pprof" "os" "runtime" "runtime/pprof" @@ -621,9 +620,9 @@ func main() { if err != nil { log.Fatal(err) } + defer f.Close() pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() - } if *scheduledShutdown != "" { shutdownDur, err := utils.ParseDurationWithSecs(*scheduledShutdown) diff --git a/engine/account.go b/engine/account.go index 25b75ce80..1570272e9 100644 --- a/engine/account.go +++ b/engine/account.go @@ -505,7 +505,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo // get the default money balanance // and go negative on it with the amount still unpaid if len(leftCC.Timespans) > 0 && leftCC.Cost > 0 && !ub.AllowNegative && !dryRun { - utils.Logger.Err(fmt.Sprintf(" Going negative on account %s with AllowNegative: false", cd.GetAccountKey())) + utils.Logger.Warning(fmt.Sprintf(" Going negative on account %s with AllowNegative: false", cd.GetAccountKey())) } leftCC.Timespans.Decompress() for tsIndex, ts := range leftCC.Timespans { diff --git a/engine/balances.go b/engine/balances.go index c9a8d8592..ff6b85c63 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -483,7 +483,7 @@ func (b *Balance) debitUnits(cd *CallDescriptor, ub *Account, moneyBalances Bala } } if cost != 0 && moneyBal == nil && (!dryRun || ub.AllowNegative) { // Fix for issue #685 - utils.Logger.Err(fmt.Sprintf(" Going negative on account %s with AllowNegative: false", cd.GetAccountKey())) + utils.Logger.Warning(fmt.Sprintf(" Going negative on account %s with AllowNegative: false", cd.GetAccountKey())) moneyBal = ub.GetDefaultMoneyBalance() } if (cost == 0 || moneyBal != nil) && b.GetValue() >= amount {