Skip to content

Commit d17b047

Browse files
authored
Merge pull request #39274 from Zhuzhenghao/scheduling-framework
[zh] Resync scheduling-framework.md
2 parents f4aca92 + aa17399 commit d17b047

File tree

1 file changed

+76
-46
lines changed

1 file changed

+76
-46
lines changed

content/zh-cn/docs/concepts/scheduling-eviction/scheduling-framework.md

Lines changed: 76 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ weight: 60
1616

1717
<!-- overview -->
1818

19-
{{< feature-state for_k8s_version="1.19" state="stable" >}}
19+
{{< feature-state for_k8s_version="v1.19" state="stable" >}}
2020

2121
<!--
2222
The scheduling framework is a pluggable architecture for the Kubernetes scheduler.
@@ -32,6 +32,8 @@ framework.
3232
请参考[调度框架的设计提案](https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/624-scheduling-framework/README.md)
3333
获取框架设计的更多技术信息。
3434

35+
[kep]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/624-scheduling-framework/README.md
36+
3537
<!-- body -->
3638

3739
<!--
@@ -110,11 +112,11 @@ stateful tasks.
110112

111113
<!--
112114
These plugins are used to sort Pods in the scheduling queue. A queue sort plugin
113-
essentially provides a `less(Pod1, Pod2)` function. Only one queue sort
115+
essentially provides a `Less(Pod1, Pod2)` function. Only one queue sort
114116
plugin may be enabled at a time.
115117
-->
116118
这些插件用于对调度队列中的 Pod 进行排序。
117-
队列排序插件本质上提供 `less(Pod1, Pod2)` 函数。
119+
队列排序插件本质上提供 `Less(Pod1, Pod2)` 函数。
118120
一次只能启动一个队列插件。
119121

120122
<!--
@@ -215,7 +217,7 @@ many blinking lights they have.
215217

216218
```go
217219
func ScoreNode(_ *v1.pod, n *v1.Node) (int, error) {
218-
return getBlinkingLightCount(n)
220+
return getBlinkingLightCount(n)
219221
}
220222
```
221223

@@ -229,13 +231,13 @@ extension point.
229231

230232
```go
231233
func NormalizeScores(scores map[string]int) {
232-
highest := 0
233-
for _, score := range scores {
234-
highest = max(highest, score)
235-
}
236-
for node, score := range scores {
237-
scores[node] = score*NodeScoreMax/highest
238-
}
234+
highest := 0
235+
for _, score := range scores {
236+
highest = max(highest, score)
237+
}
238+
for node, score := range scores {
239+
scores[node] = score*NodeScoreMax/highest
240+
}
239241
}
240242
```
241243

@@ -245,31 +247,62 @@ aborted.
245247
-->
246248
如果任何 NormalizeScore 插件返回错误,则调度阶段将终止。
247249

250+
{{< note >}}
248251
<!--
249252
Plugins wishing to perform "pre-reserve" work should use the
250253
NormalizeScore extension point.
251254
-->
252-
{{< note >}}
253255
希望执行“预保留”工作的插件应该使用 NormalizeScore 扩展点。
254256
{{< /note >}}
255257

258+
### Reserve {#reserve}
259+
256260
<!--
257-
### Reserve
261+
A plugin that implements the Reserve extension has two methods, namely `Reserve`
262+
and `Unreserve`, that back two informational scheduling phases called Reserve
263+
and Unreserve, respectively. Plugins which maintain runtime state (aka "stateful
264+
plugins") should use these phases to be notified by the scheduler when resources
265+
on a node are being reserved and unreserved for a given Pod.
258266
-->
259-
### Reserve
267+
实现了 Reserve 扩展的插件,拥有两个方法,即 `Reserve``Unreserve`
268+
他们分别支持两个名为 Reserve 和 Unreserve 的信息处理性质的调度阶段。
269+
维护运行时状态的插件(又称 "有状态插件")应该使用这两个阶段,
270+
以便在节点上的资源被保留和未保留给特定的 Pod 时得到调度器的通知。
260271

261272
<!--
262-
This is an informational extension point. Plugins which maintain runtime state
263-
(aka "stateful plugins") should use this extension point to be notified by the
264-
scheduler when resources on a node are being reserved for a given Pod. This
265-
happens before the scheduler actually binds the Pod to the Node, and it exists
266-
to prevent race conditions while the scheduler waits for the bind to succeed.
273+
The Reserve phase happens before the scheduler actually binds a Pod to its
274+
designated node. It exists to prevent race conditions while the scheduler waits
275+
for the bind to succeed. The `Reserve` method of each Reserve plugin may succeed
276+
or fail; if one `Reserve` method call fails, subsequent plugins are not executed
277+
and the Reserve phase is considered to have failed. If the `Reserve` method of
278+
all plugins succeed, the Reserve phase is considered to be successful and the
279+
rest of the scheduling cycle and the binding cycle are executed.
267280
-->
268-
Reserve 是一个信息性的扩展点。
269-
管理运行时状态的插件(也成为“有状态插件”)应该使用此扩展点,以便
270-
调度器在节点给指定 Pod 预留了资源时能够通知该插件。
271-
这是在调度器真正将 Pod 绑定到节点之前发生的,并且它存在是为了防止
272-
在调度器等待绑定成功时发生竞争情况。
281+
Reserve 阶段发生在调度器实际将一个 Pod 绑定到其指定节点之前。
282+
它的存在是为了防止在调度器等待绑定成功时发生竞争情况。
283+
每个 Reserve 插件的 `Reserve` 方法可能成功,也可能失败;
284+
如果一个 `Reserve` 方法调用失败,后面的插件就不会被执行,Reserve 阶段被认为失败。
285+
如果所有插件的 `Reserve` 方法都成功了,Reserve 阶段就被认为是成功的,
286+
剩下的调度周期和绑定周期就会被执行。
287+
288+
<!--
289+
The Unreserve phase is triggered if the Reserve phase or a later phase fails.
290+
When this happens, the `Unreserve` method of **all** Reserve plugins will be
291+
executed in the reverse order of `Reserve` method calls. This phase exists to
292+
clean up the state associated with the reserved Pod.
293+
-->
294+
如果 Reserve 阶段或后续阶段失败了,则触发 Unreserve 阶段。
295+
发生这种情况时,**所有** Reserve 插件的 `Unreserve` 方法将按照
296+
`Reserve` 方法调用的相反顺序执行。
297+
这个阶段的存在是为了清理与保留的 Pod 相关的状态。
298+
299+
{{< caution >}}
300+
<!--
301+
The implementation of the `Unreserve` method in Reserve plugins must be
302+
idempotent and may not fail.
303+
-->
304+
Reserve 插件中 `Unreserve` 方法的实现必须是幂等的,并且不能失败。
305+
{{< /caution >}}
273306

274307
<!--
275308
This is the last step in a scheduling cycle. Once a Pod is in the reserved
@@ -303,42 +336,41 @@ _Permit_ 插件在每个 Pod 调度周期的最后调用,用于防止或延迟
303336
<!--
304337
1. **deny** \
305338
If any Permit plugin denies a Pod, it is returned to the scheduling queue.
306-
This will trigger [Unreserve](#unreserve) plugins.
339+
This will trigger the Unreserve phase in [Reserve plugins](#reserve).
307340
-->
308341
1. **拒绝** \
309342
如果任何 Permit 插件拒绝 Pod,则该 Pod 将被返回到调度队列。
310-
这将触发[Unreserve](#unreserve) 插件
343+
这将触发 [Reserve 插件](#reserve)中的 Unreserve 阶段
311344

312345
<!--
313346
1. **wait** (with a timeout) \
314347
If a Permit plugin returns "wait", then the Pod is kept in an internal "waiting"
315348
Pods list, and the binding cycle of this Pod starts but directly blocks until it
316-
gets [approved](#frameworkhandle). If a timeout occurs, **wait** becomes **deny**
317-
and the Pod is returned to the scheduling queue, triggering [Unreserve](#unreserve)
318-
plugins.
349+
gets approved. If a timeout occurs, **wait** becomes **deny**
350+
and the Pod is returned to the scheduling queue, triggering the
351+
Unreserve phase in [Reserve plugins](#reserve).
319352
-->
320353
1. **等待**(带有超时) \
321354
如果一个 Permit 插件返回 “等待” 结果,则 Pod 将保持在一个内部的 “等待中”
322-
的 Pod 列表,同时该 Pod 的绑定周期启动时即直接阻塞直到得到
323-
[批准](#frameworkhandle)。如果超时发生,**等待** 变成 **拒绝**,并且 Pod
324-
将返回调度队列,从而触发 [Unreserve](#unreserve) 插件。
325-
355+
的 Pod 列表,同时该 Pod 的绑定周期启动时即直接阻塞直到得到批准。
356+
如果超时发生,**等待** 变成 **拒绝**,并且 Pod
357+
将返回调度队列,从而触发 [Reserve 插件](#reserve)中的 Unreserve 阶段。
326358

359+
{{< note >}}
327360
<!--
328361
While any plugin can access the list of "waiting" Pods and approve them
329362
(see [`FrameworkHandle`](https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle)), we expect only the permit
330363
plugins to approve binding of reserved Pods that are in "waiting" state. Once a Pod
331364
is approved, it is sent to the [PreBind](#pre-bind) phase.
332365
-->
333-
{{< note >}}
334366
尽管任何插件可以访问 “等待中” 状态的 Pod 列表并批准它们
335367
(查看 [`FrameworkHandle`](https://git.k8s.io/enhancements/keps/sig-scheduling/624-scheduling-framework#frameworkhandle))。
336368
我们期望只有允许插件可以批准处于 “等待中” 状态的预留 Pod 的绑定。
337369
一旦 Pod 被批准了,它将发送到 [PreBind](#pre-bind) 阶段。
338370
{{< /note >}}
339371

340372
<!--
341-
### Pre-bind {#pre-bind}
373+
### PreBind {#pre-bind}
342374
-->
343375
### PreBind {#pre-bind}
344376

@@ -352,10 +384,10 @@ target node before allowing the Pod to run there.
352384
将其挂载到目标节点上。
353385

354386
<!--
355-
If any PreBind plugin returns an error, the Pod is [rejected](#unreserve) and
387+
If any PreBind plugin returns an error, the Pod is [rejected](#reserve) and
356388
returned to the scheduling queue.
357389
-->
358-
如果任何 PreBind 插件返回错误,则 Pod 将被 [拒绝](#unreserve) 并且
390+
如果任何 PreBind 插件返回错误,则 Pod 将被 [拒绝](#reserve) 并且
359391
退回到调度队列中。
360392

361393
<!--
@@ -422,26 +454,26 @@ interfaces have the following form.
422454

423455
```go
424456
type Plugin interface {
425-
Name() string
457+
Name() string
426458
}
427459

428460
type QueueSortPlugin interface {
429-
Plugin
430-
Less(*v1.pod, *v1.pod) bool
461+
Plugin
462+
Less(*v1.pod, *v1.pod) bool
431463
}
432464

433465
type PreFilterPlugin interface {
434-
Plugin
435-
PreFilter(context.Context, *framework.CycleState, *v1.pod) error
466+
Plugin
467+
PreFilter(context.Context, *framework.CycleState, *v1.pod) error
436468
}
437469

438470
// ...
439471
```
440472

441473
<!--
442-
# Plugin Configuration
474+
## Plugin configuration
443475
-->
444-
# 插件配置
476+
## 插件配置
445477

446478
<!--
447479
You can enable or disable plugins in the scheduler configuration. If you are using
@@ -471,5 +503,3 @@ Learn more at [multiple profiles](/docs/reference/scheduling/config/#multiple-pr
471503
如果你正在使用 Kubernetes v1.18 或更高版本,你可以将一组插件设置为
472504
一个调度器配置文件,然后定义不同的配置文件来满足各类工作负载。
473505
了解更多关于[多配置文件](/zh-cn/docs/reference/scheduling/config/#multiple-profiles)
474-
475-

0 commit comments

Comments
 (0)