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

Abstract Resources #256

Merged
merged 11 commits into from
Oct 19, 2020
Merged

Abstract Resources #256

merged 11 commits into from
Oct 19, 2020

Conversation

jschwinger233
Copy link
Member

@jschwinger233 jschwinger233 commented Sep 23, 2020

指导思想

  1. DeployOptions 里不再有各个资源, 而是统一的 []ResourceRequest
  2. 划清了 NodeInfo 的使用边界
    a. NodeInfo 分拆为两个对象 NodeInfo + StrategyInfo, 新 NodeInfo 负责给 scheduler 提供信息, StrategyInfo 为 strategy deploy 提供信息
    b. scheduler 和 strategy 的返回信息不再记录在 NodeInfo 和 StrategyInfo 里, 而是单独返回数据结构
    c. NodeInfo 只出现在 SelectNode 函数里, StrategyInfo 只出现在 strategy.Deploy 里, 不泄漏, 不滥用
  3. 事务
    a. doAllocResource 不再提交变更给 store, 只做计算, 提交变更由上层完成, 便于实现事务
    b. doCreateWorkloads 实现资源元数据事务, 对资源元数据的提交和回滚都 在这个函数里实现
    c. doDeployOneWorkload 实现容器元数据的提交, 容器元数据和容器实例的一致性在这个函数里保证

cluster/calcium/create.go Outdated Show resolved Hide resolved
rpc/transform.go Outdated Show resolved Hide resolved
// ResourceMemory .
ResourceMemory
// ResourceVolume .
ResourceVolume
ResourceVolumeNeedSchedule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResourceScheduledVolume

types/node.go Outdated
ResourceCPU: n.CPUUsed / float64(len(n.InitCPU)),
ResourceMemory: 1.0 - float64(n.MemCap)/float64(n.InitMemCap),
ResourceStorage: n.StorageUsage(),
ResourceVolume: float64(n.VolumeUsed) / float64(n.Volume.Total()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在想 CPU 和 CPU CORE 是不是应该算2类资源

close(ch)

for nodename := range deployMap {
if e := c.store.DeleteProcessing(ctx, opts, nodename); e != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

憋偷懒。。。里面都是 err


// if: alloc resources
func(ctx context.Context) error {
return c.withNodesLocked(ctx, opts.Podname, opts.Nodename, opts.NodeLabels, false, func(nodeMap map[string]*types.Node) (err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我记得我改过这个接口了?第二个参数是 opts.Nodenames, 是个 []string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以有冲突来着... 变基

@jschwinger233
Copy link
Member Author

可以直接看新的 create.go / realloc.go, 看 diff 太蛋疼了

@CMGS
Copy link
Contributor

CMGS commented Oct 12, 2020

可以直接看新的 create.go / realloc.go, 看 diff 太蛋疼了

那么哪里可以看到新的。。

@jschwinger233
Copy link
Member Author

@CMGS
Copy link
Contributor

CMGS commented Oct 12, 2020

可以直接看新的 create.go / realloc.go, 看 diff 太蛋疼了

那么哪里可以看到新的。。

https://github.com/projecteru2/core/blob/07fe7c4c0f6cf6e21a095fa35a060ea82a1c1a80/cluster/calcium/create.go
https://github.com/projecteru2/core/blob/07fe7c4c0f6cf6e21a095fa35a060ea82a1c1a80/cluster/calcium/realloc.go

不过不能 comment

哦,我已经拿最新的用 vscode 看了……不然看不下去……

@@ -147,10 +150,10 @@ func (vbs VolumeBindings) ApplyPlan(plan VolumePlan) (res VolumeBindings) {
return
}

// Merge combines two VolumeBindings
func (vbs VolumeBindings) Merge(vbs2 VolumeBindings) (softVolumes VolumeBindings, hardVolumes VolumeBindings, err error) {
// MergeVolumeBindings combines two VolumeBindings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确定是 export 的么

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是吧, realloc 里要用, realloc 的请求是增量, 所以需要把已有的 volume 和增量 volume 合体

@CMGS
Copy link
Contributor

CMGS commented Oct 14, 2020

types, complex, rpc 覆盖率下降了

@CMGS
Copy link
Contributor

CMGS commented Oct 14, 2020

另外不考虑把 types/scheduler 的定义啊什么的放 scheduler 里面么……觉得这里放 interface 什么的怪怪的

@jschwinger233
Copy link
Member Author

另外不考虑把 types/scheduler 的定义啊什么的放 scheduler 里面么……觉得这里放 interface 什么的怪怪的

循环依赖..
如果放到 scheduler 里, 那么 types.DeployOptions 需要 import scheduler, 而 scheduler 也要 import types...

@jschwinger233
Copy link
Member Author

types, complex, rpc 覆盖率下降了

逼太紧😂

@CMGS
Copy link
Contributor

CMGS commented Oct 14, 2020

另外不考虑把 types/scheduler 的定义啊什么的放 scheduler 里面么……觉得这里放 interface 什么的怪怪的

循环依赖..
如果放到 scheduler 里, 那么 types.DeployOptions 需要 import scheduler, 而 scheduler 也要 import types...

我的意思是在 scheduler 里面有个 types 的包,全局 types 依赖于这个模块的 types,而 scheduler 的实现依赖于全局 types 和自己的 types 不就好了

@CMGS
Copy link
Contributor

CMGS commented Oct 14, 2020

types, complex, rpc 覆盖率下降了

逼太紧😂

😈

@jschwinger233
Copy link
Member Author

另外不考虑把 types/scheduler 的定义啊什么的放 scheduler 里面么……觉得这里放 interface 什么的怪怪的

循环依赖..
如果放到 scheduler 里, 那么 types.DeployOptions 需要 import scheduler, 而 scheduler 也要 import types...

我的意思是在 scheduler 里面有个 types 的包,全局 types 依赖于这个模块的 types,而 scheduler 的实现依赖于全局 types 和自己的 types 不就好了

好像不太容易, 因为 scheduler types 依赖 global types (NodeInfo, Node), 而 global types 也要依赖 scheudler types (DeployOptions.ResourceRequests 是 interface) ...

@jschwinger233
Copy link
Member Author

types, complex, rpc 覆盖率下降了

complex 覆盖率下降是因为模块代码减少了... 其他的都改了

@jschwinger233 jschwinger233 changed the title [WIP] Abstract Resources Abstract Resources Oct 15, 2020
@jschwinger233
Copy link
Member Author

果然还是测出来了两个 bug, 现在应该可以了

@CMGS CMGS merged commit 8959710 into projecteru2:master Oct 19, 2020
CMGS pushed a commit that referenced this pull request Oct 19, 2020
* intro scheduler v2: adapter to v1

* cluster: rewrite create and realloc

* types: introduce resource interface to unify

* scheduler: expose SelectNodes to encap ScheduleV1

* store: new UpdateNodes and Processing interfaces

* strategy: adjust to new resource data structure

* rpc: create option harness resource interface

* utils: minor fix to transaction

* pass lint and codacy

* fix transactions for realloc and replace
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 this pull request may close these issues.

2 participants