score

package
v0.0.0-...-9e299b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateCollectScore

func CalculateCollectScore(state *framework.CycleState, node *nodeinfo.NodeInfo, vgs []string, f *framework.FrameworkHandle, p *v1.Pod) (int64, error)

func CalculateValueScore

func CalculateValueScore(value string, state *framework.CycleState, node *nodeinfo.NodeInfo) (int64, error)

容量超分算法实现

availsocre*系数+(所有PVC(limit-request))*系数+((vgpoolsize-tatalpvclimit)*系数 三个数字大概范围值 ,相差不大,所以系数不用相差太大,系数的主要目的,是为了突出一个维度的重要性

pvc limit 10G,reqest=5G NODE 5是空的,计算出来的分数,基于PVC availvgpvc:50G (所有PVC(limit-request)/PVC数目) 5G (limit 10,reque5G) ((vgpoolsize-tatalpvclimit)/所有的THINVG) 40G

node上面之前已经有一个PVC,limit 3G request 2g

availvgpvc:49G (所有PVC(limit-request)/PVC数目) (5G+1G)/2= 3G ((vgpoolsize-tatalpvclimit)/所有的THINVG) 50G-(10g+3)

为什么要除以PVC数目以及所有thinvg的数目,如果不这样,这两个分数太大,会影响availsocre分数,对我来说,availsocre占比应该最大为5,后面1,2

一共三个系数,也就是三个维度,找一个维度是1,其它维度根据相对值,设置具体的值,例如空间维度是1. 其它维度可以相对设为2,3

验证逻辑:

  1.availsocre:两个node,谁可用空间越大,就调度到那个NODE(计算可用空间,包含超分VG,和正常VG)
  2.所有PVC(limit-request)/PVC数目:两个NODE,谁可以超分越大,越建议调度到那个结点,超分范围由limit-requst决定,如果两个NODE,每个上面一个PVC, 一个(limit-requst)=5.一个(limit-reques)=2,说明5那个NODE关联的thin vg超分比率更大
            limit-requst计算公式:所有的PVC的limit-requst相加/pvc的数目

	    一个node上面没有PVC,一个NODE上面有一个PVC,limit-quest=5. 基于这个公式会优先调试到5那个NODE上面,因为如果没有PVC的NODE,对我来说,超分得到的分数就是0,逻辑上是合理的,

  3.(vgpoolsize-tatalpvclimit),两个NODE,一个NODE上面已经有一个PVC,alllimit=10 别一个NODE上面没有PVC,没有PVC的NODE得分更高等于vgpoolsize, 有PVC分数得分更底,vgpoolsize-10(如果分配过多,可能是负值)
     设计的目的,就是如果这个VG总容量被超分,超分的越多,减去的分数越大,

func CheckContailThinInVgs

func CheckContailThinInVgs(pod *v1.Pod, f *framework.FrameworkHandle) bool

func GetAllPVCForSameThinVG

func GetAllPVCForSameThinVG(node *nodeinfo.NodeInfo, f *framework.FrameworkHandle, p *v1.Pod) (map[string][]*v1.PersistentVolumeClaim, error)

func GetAllPVCLimitPlusVGThin

func GetAllPVCLimitPlusVGThin(allvgpvc map[string][]*v1.PersistentVolumeClaim, node *nodeinfo.NodeInfo) int64
func GetLimitPlusRequest(allvgpvc map[string][]*v1.PersistentVolumeClaim) int64 {
	var res int64

	for thinname, pvcs := range allvgpvc {
		for _, pvc := range pvcs {
			if _, ok := pvc.Spec.Resources.Limits["storage"]; !ok {
				continue
			} else {
				limit := pvc.Spec.Resources.Limits["storage"]
				request := pvc.Spec.Resources.Requests["storage"]
				if limit.Value() > request.Value() {
					res = res + (limit.Value() - request.Value())
				}
				fmt.Printf("GetLimitPlusRequest thin is %s,limit is %d,requst is %d ,res is %d \n", thinname, limit.Value(), request.Value(), res)
			}
		}
	}

	fmt.Printf("GetLimitPlusRequest total is %d \n", res)

	return res
}

func Score

func Score(state *framework.CycleState, node *nodeinfo.NodeInfo, vgs []string, f *framework.FrameworkHandle, p *v1.Pod) (int64, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL