Fix the share percentage
This fix solves the problem of the calculation of the user share which keeps memory of deleted users. bug: #1663644 Change-Id: Ie591b60a413ab16c90fa6adc5a1f5be3046e0122 Sem-Ver: bugfix
This commit is contained in:
parent
a00088c413
commit
e45ce144b4
@ -1,7 +1,6 @@
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from common.user import User
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from oslo_config import cfg
|
||||
@ -191,7 +190,6 @@ class FairShareManager(Manager):
|
||||
data["memory"] = float(0)
|
||||
|
||||
for period in xrange(self.periods):
|
||||
default_share = self.default_share
|
||||
decay = self.decay_weight ** period
|
||||
from_date = to_date - timedelta(days=(self.period_length))
|
||||
time_window_from_date = from_date
|
||||
@ -201,25 +199,15 @@ class FairShareManager(Manager):
|
||||
prj_id, from_date, to_date)
|
||||
|
||||
for user_id, usage_rec in usages.items():
|
||||
user = project.getUser(id=user_id)
|
||||
|
||||
if not user:
|
||||
user = User()
|
||||
user.setId(user_id)
|
||||
user.getShare().setValue(default_share)
|
||||
|
||||
data = user.getData()
|
||||
data["vcpus"] = float(0)
|
||||
data["memory"] = float(0)
|
||||
|
||||
project.addUser(user)
|
||||
|
||||
decay_vcpus = decay * usage_rec["vcpus"]
|
||||
decay_memory = decay * usage_rec["memory"]
|
||||
|
||||
data = user.getData()
|
||||
data["vcpus"] += decay_vcpus
|
||||
data["memory"] += decay_memory
|
||||
user = project.getUser(id=user_id)
|
||||
|
||||
if user:
|
||||
data = user.getData()
|
||||
data["vcpus"] += decay_vcpus
|
||||
data["memory"] += decay_memory
|
||||
|
||||
total_vcpus += decay_vcpus
|
||||
total_memory += decay_memory
|
||||
|
Loading…
x
Reference in New Issue
Block a user