satellite/accounting: bugfix infinit storage usage increase (#3916)
* satellite/accounting: bugfix infinit storage usage increase * support int64 values Co-authored-by: JT Olio <hello@jtolio.com>
This commit is contained in:
parent
c40d5043e1
commit
e1a18ce974
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@ -44,8 +45,8 @@ func (cache *redisLiveAccounting) GetProjectStorageUsage(ctx context.Context, pr
|
||||
}
|
||||
return 0, Error.Wrap(err)
|
||||
}
|
||||
intval, err := strconv.Atoi(string(val))
|
||||
return int64(intval), Error.Wrap(err)
|
||||
intval, err := strconv.ParseInt(string([]byte(val)), 10, 64)
|
||||
return intval, Error.Wrap(err)
|
||||
}
|
||||
|
||||
// createBandwidthProjectIDKey creates the bandwidth project key.
|
||||
@ -65,8 +66,8 @@ func (cache *redisLiveAccounting) GetProjectBandwidthUsage(ctx context.Context,
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
intval, err := strconv.Atoi(string(val))
|
||||
return int64(intval), Error.Wrap(err)
|
||||
intval, err := strconv.ParseInt(string([]byte(val)), 10, 64)
|
||||
return intval, Error.Wrap(err)
|
||||
}
|
||||
|
||||
// UpdateProjectBandwidthUsage increment the bandwidth cache key value.
|
||||
@ -115,11 +116,13 @@ func (cache *redisLiveAccounting) GetAllProjectTotals(ctx context.Context) (_ ma
|
||||
}
|
||||
id := new(uuid.UUID)
|
||||
copy(id[:], item.Key[:])
|
||||
intval, err := strconv.Atoi(string(item.Value))
|
||||
intval, err := strconv.ParseInt(string([]byte(item.Value)), 10, 64)
|
||||
if err != nil {
|
||||
return Error.New("could not get total for project %s", id.String())
|
||||
}
|
||||
projects[*id] = int64(intval)
|
||||
if !strings.HasSuffix(item.Key.String(), "bandwidth") {
|
||||
projects[*id] = intval
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user