Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate Capacity Return negative Capacity #455

Closed
chrisxuwq opened this issue Jul 8, 2021 · 1 comment · Fixed by #456
Closed

Calculate Capacity Return negative Capacity #455

chrisxuwq opened this issue Jul 8, 2021 · 1 comment · Fixed by #456
Assignees

Comments

@chrisxuwq
Copy link

DEBU[2021-07-07 10:36:23] [10.22.68.121:55768-MkwexgFP] [strategy.Deploy] infos [{Nodename:spp-qa-vm-node-1 Usage:0.07999999999999996 Rate:3.725290298461914e-08 Capacity:10726691 Count:7} {Nodename:spp-qa-vm-node-2 Usage:0.24 Rate:3.725290298461914e-08 Capacity:4290676 Count:5} {Nodename:spp-qa-vm-node-3 Usage:0.45999999999999996 Rate:3.725290298461914e-08 Capacity:4290676 Count:6}], need 1, total 19308043, limit 1
DEBU[2021-07-07 10:36:23] [10.22.68.121:55768-MkwexgFP] [GlobalPlan] strategyInfos: [{spp-qa-vm-node-1 0.07999999999999996 3.725290298461914e-08 -9223372036844049117 7} {spp-qa-vm-node-2 0.24 3.725290298461914e-08 4290676 5} {spp-qa-vm-node-3 0.45999999999999996 3.725290298461914e-08 4290676 6}]
INFO[2021-07-07 10:36:23] [10.22.68.121:55768-MkwexgFP] [Calium.doAllocResource] deployMap: map[spp-qa-vm-node-1:-9223372036854775808]

Called calculator capacity and it returned a negative capacity on one node: map[spp-qa-vm-node-1:-9223372036854775808] suppose would be an error?

@jschwinger233 jschwinger233 self-assigned this Jul 8, 2021
@jschwinger233
Copy link
Member

> github.com/projecteru2/core/strategy.GlobalPlan() ./strategy/global.go:43 (PC: 0x887fe3)
    38:				if strategyInfos[j].Capacity == 0 {
    39:					continue
    40:				}
    41:				cost := utils.Round(strategyInfos[j].Rate)
    42:				deploy = int(delta / cost)
=>  43:				if deploy == 0 {
    44:					deploy = 1
    45:				}
    46:				if deploy > strategyInfos[j].Capacity {
    47:					deploy = strategyInfos[j].Capacity
    48:				}
(dlv) p deploy
-9223372036854775808
(dlv) p delta
0.16
(dlv) p cost
0

和我想的一样, 还是 utils.Round 把 Rate 化成 0 了.
我先检查一下 Rate 的计算有没有问题, 没问题就把 Round 修一下.

@jschwinger233 jschwinger233 linked a pull request Jul 8, 2021 that will close this issue
@CMGS CMGS closed this as completed in #456 Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants