feat: add container restart storage test
This commit is contained in:
24
README.md
Normal file
24
README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Container restart file test
|
||||
|
||||
用于测试当前平台在程序正常执行完成、退出码为 `0`、随后自动重启容器时,容器内 `/app` 文件是否保留。
|
||||
|
||||
镜像启动时会检查并写入 `/app/restart-marker.txt`,在 8080 端口提供 `/health`,默认运行 60 秒后以退出码 0 正常退出。
|
||||
|
||||
构建并推送:
|
||||
|
||||
```bash
|
||||
docker build -t <registry>/k8s-restart-storage-test:<tag> .
|
||||
docker push <registry>/k8s-restart-storage-test:<tag>
|
||||
```
|
||||
|
||||
平台每次启动时查看日志。如果每次都是:
|
||||
|
||||
```text
|
||||
marker_existed_before_start=false
|
||||
```
|
||||
|
||||
表示上次写入的文件已经丢失。如果第二次及之后显示 `true`,表示平台的这种重启方式保留了容器内文件。
|
||||
|
||||
日志中的 `pod_name` 相同通常表示同一个 Pod 内重启,名称改变表示创建了新 Pod。平台如果注入了 `POD_UID` 环境变量,日志也会一并打印。
|
||||
|
||||
可通过环境变量 `RUN_SECONDS` 调整正常退出前的运行秒数。
|
||||
Reference in New Issue
Block a user