Skip to content

Commit f806c6a

Browse files
authored
Merge pull request #31684 from douglarek/patch-1
[zh-docs] typo fix
2 parents f9c11cf + a1ec586 commit f806c6a

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

content/zh/docs/concepts/containers/container-lifecycle-hooks.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ less than the total time (55+10) it takes for these two things to happen.
158158
`PreStop` 回调并不会与停止容器的信号处理程序异步执行;回调必须在
159159
可以发送信号之前完成执行。
160160
如果 `PreStop` 回调在执行期间停滞不前,Pod 的阶段会变成 `Terminating`
161-
并且一致处于该状态,直到其 `terminationGracePeriodSeconds` 耗尽为止,
161+
并且一直处于该状态,直到其 `terminationGracePeriodSeconds` 耗尽为止,
162162
这时 Pod 会被杀死。
163163
这一宽限期是针对 `PreStop` 回调的执行时间及容器正常停止时间的总和而言的。
164164
例如,如果 `terminationGracePeriodSeconds` 是 60,回调函数花了 55 秒钟
@@ -214,30 +214,32 @@ The logs for a Hook handler are not exposed in Pod events.
214214
If a handler fails for some reason, it broadcasts an event.
215215
For `PostStart`, this is the `FailedPostStartHook` event,
216216
and for `PreStop`, this is the `FailedPreStopHook` event.
217-
You can see these events by running `kubectl describe pod <pod_name>`.
218-
Here is some example output of events from running this command:
217+
To generate a failed `FailedPreStopHook` event yourself, modify the [lifecycle-events.yaml](https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/lifecycle-events.yaml) file to change the postStart command to "badcommand" and apply it.
218+
Here is some example output of the resulting events you see from running `kubectl describe pod lifecycle-demo`:
219219
-->
220220
### 调试回调处理程序
221221

222222
回调处理程序的日志不会在 Pod 事件中公开。
223223
如果处理程序由于某种原因失败,它将播放一个事件。
224224
对于 `PostStart`,这是 `FailedPostStartHook` 事件,对于 `PreStop`,这是 `FailedPreStopHook` 事件。
225-
您可以通过运行 `kubectl describe pod <pod_name>` 命令来查看这些事件。
226-
下面是运行这个命令的一些事件输出示例:
225+
要自己生成失败的 `FailedPreStopHook` 事件,请修改
226+
[lifecycle-events.yaml](https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/lifecycle-events.yaml)
227+
文件将 postStart 命令更改为 ”badcommand“ 并应用它。
228+
以下是通过运行 `kubectl describe pod lifecycle-demo` 后你看到的一些结果事件的示例输出:
227229

228230
```
229231
Events:
230-
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
231-
--------- -------- ----- ---- ------------- -------- ------ -------
232-
1m 1m 1 {default-scheduler } Normal Scheduled Successfully assigned test-1730497541-cq1d2 to gke-test-cluster-default-pool-a07e5d30-siqd
233-
1m 1m 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Pulling pulling image "test:1.0"
234-
1m 1m 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Created Created container with docker id 5c6a256a2567; Security:[seccomp=unconfined]
235-
1m 1m 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Pulled Successfully pulled image "test:1.0"
236-
1m 1m 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Started Started container with docker id 5c6a256a2567
237-
38s 38s 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Killing Killing container with docker id 5c6a256a2567: PostStart handler: Error executing in Docker Container: 1
238-
37s 37s 1 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Normal Killing Killing container with docker id 8df9fdfd7054: PostStart handler: Error executing in Docker Container: 1
239-
38s 37s 2 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "main" with RunContainerError: "PostStart handler: Error executing in Docker Container: 1"
240-
1m 22s 2 {kubelet gke-test-cluster-default-pool-a07e5d30-siqd} spec.containers{main} Warning FailedPostStartHook
232+
Type Reason Age From Message
233+
---- ------ ---- ---- -------
234+
Normal Scheduled 7s default-scheduler Successfully assigned default/lifecycle-demo to ip-XXX-XXX-XX-XX.us-east-2...
235+
Normal Pulled 6s kubelet Successfully pulled image "nginx" in 229.604315ms
236+
Normal Pulling 4s (x2 over 6s) kubelet Pulling image "nginx"
237+
Normal Created 4s (x2 over 5s) kubelet Created container lifecycle-demo-container
238+
Normal Started 4s (x2 over 5s) kubelet Started container lifecycle-demo-container
239+
Warning FailedPostStartHook 4s (x2 over 5s) kubelet Exec lifecycle hook ([badcommand]) for Container "lifecycle-demo-container" in Pod "lifecycle-demo_default(30229739-9651-4e5a-9a32-a8f1688862db)" failed - error: command 'badcommand' exited with 126: , message: "OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: \"badcommand\": executable file not found in $PATH: unknown\r\n"
240+
Normal Killing 4s (x2 over 5s) kubelet FailedPostStartHook
241+
Normal Pulled 4s kubelet Successfully pulled image "nginx" in 215.66395ms
242+
Warning BackOff 2s (x2 over 3s) kubelet Back-off restarting failed container
241243
```
242244

243245
## {{% heading "whatsnext" %}}

0 commit comments

Comments
 (0)