Skip to content

[feat] Admission control needed #45

@linxuyalun

Description

@linxuyalun

pkg/runner/fnscheduler/fnscheduler.go 下的代码为例子进行说明,

// Refresh refreshes information of instances and does scaling.
// Everytime when ScheduleHandler recieves a new event for upstream,
// it decides the status of the instance, and calls Refresh.
func (fs *FunctionScheduler) Refresh(functionName string, target int) {
	zap.S().Debugw("refresh", "function", functionName)

	ins, existed := fs.instances[functionName]
	if !existed {
		zap.S().Panicw("instance set not initialized", "function", functionName)
	}

	ins.Scale(target, functionName)
	// FIXME: when trigger, the process status may not still running, update the logic here
	fs.trigger <- struct{}{}
}

这里在 Scale 完成后会触发 trigger,trigger 做的事情就是去和 k8s 的同步。这里是存在一个偏差的,这时候进程完成了注册,但是不一定真的已经处于一个 running 的状态,目前由于 Scale 如果完成了创建新进程,必须通过 canCreateInstance 函数,因此这里的假设是当 Scale 结束后,如果可以创建一定能创建成功。

等到后续如果 cGroups 相关的实现完成后,需要添加一个 admission 相关的 logic,函数进来创建条件通过后,先对可用容量进行一个调整,再进行相关创建。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions