doker 1.12-runc源码逻辑跳转流程分析

简介:

入口1–>runc处理(2)中处理-->至libcontainer处理(3)


wKioL1iEFzmCmc2MAAEYp47uVcI374.png


第一步runc代码处理

checkpoint 

 

checkpointCommand(main.go) —> checkpointCommand(checkpoint.go)

container

 

createCommand(main.go)—>createCommand(create.go)—>startContainer(untils_linux.go)—>run(untils_linux.go)

deleteCommand(main.go)—>deleteCommand(delete.go)—>destroy(untils_linux.go)

eventsCommand(main.go)—>eventsCommand(events.go)

execCommand(main.go)—>execCommand(exec.go)—>execProcess(exec.go)->run(untils_linux.go)

initCommand(main.go)—>initCommand(main_unix.go)

killCommand(main.go)—>killCommand(kill.go)

listCommand(main.go)—>getContainers(list.go)

pauseCommand(main.go) —>pauseCommand(pause.go)

psCommand(main.go)—>psCommand(ps.go)

restoreCommand(main.go)—>restoreCommand(restore.go)—>restoreContainer(restore.go)

resumeCommand(main.go)—>resumeCommand(pause.go)

runCommand(main.go)—>runCommand(run.go)—>startContainer(untils_linux.go)

specCommand(main.go)—>specCommand(spec.go) end

startCommand(main.go)—>startCommand(start.go)

stateCommand(main.go)—>stateCommand(state.go)

updateCommand(main.go)—>updateCommand(update.go)

第二步从runc代码处理至libcontainer处理

checkpoint

 

checkpointCommand(checkpoint.go) —>Checkpoint(libcontainer/container_linux.go)

container

run(untils_linux.go)—>Run(libcontainer/container_linux.go) 

destroy(untils_linux.go)—>Destroy(libcontainer/container_linux.go) 

eventsCommand(events.go)—>Status(libcontainer/container_linux.go)

execProcess(exec.go)—>Status\Stopped\State(libcontainer/container_linux.go)  || run(untils_linux.go)—>Start\Run\Destroy(libcontainer/container_linux.go)

 initCommand(main_unix.go)—>StartInitialization(libcontainer/factory_linux.go)

killCommand(kill.go)—>Signal(libcontainer/container_linux.go)

getContainers(list.go)—>Status\State\Stopped(libcontainer/container_linux.go)

pauseCommand(pause.go)—>Pause(libcontainer/container_linux.go)

psCommand(ps.go)—>exec.Command("ps", psArgs...).Output()

restoreContainer(restore.go)—>Restore(libcontainer/container_linux.go)

resumeCommand(pause.go)—>Resume(libcontainer/container_linux.go)

startContainer(untils_linux.go)—>Run(libcontainer/factory.go)

startCommand(start.go)—>Exec(libcontainer/container_linux.go)

stateCommand(state.go)—>State(libcontainer/container_linux.go)

updateCommand(update.go)—>Set(libcontainer/container_linux.go) 


runC源码的核心部分——Create Command & Run Command 进行源码分析。

说明点:

  • runC create command 和 run command的流程入口统一从/runc/utils_linux.go#334 main.startContainer方法,通过create flag进行区分。

  • 业务逻辑中,主要有两个step构成:

    • firstly create container filesystem and construct a linuxcontainer object by creatContainer function.

    • secondly start process in container by runner.run function.

  • 主要的逻辑在process的启动过程,注意以下几点:

    • 对于namespace的隔离,主要通过bootstrapData封装好clone flags。

    • 由sendconfig将bootstrapData封装的config传给容器起的init process。

    • 调用系统setns进行namespace和process 的associate。

    • cgroup的管理由cgroups.Manager interface进行操作,具体由各个cgroup subsystem各自实现该interface。

    • oom_score_adj and rlimits等都在这里完成设置。


wKiom1iEGJTxU4SzAA6CCAwTrnI079.jpg



本文转自 qwjhq 51CTO博客,原文链接:http://blog.51cto.com/bingdian/1893657

相关文章
|
6月前
|
自然语言处理 JavaScript
【Vue2.0源码学习】模板编译篇-模板解析阶段(整体运行流程)
【Vue2.0源码学习】模板编译篇-模板解析阶段(整体运行流程)
41 0
|
存储 监控 Java
一篇文章带你搞懂SkyWalking调用链追踪框架
介绍了Skywalking的作用,安装方法,架构设计等等
一篇文章带你搞懂SkyWalking调用链追踪框架
|
5月前
|
JSON 数据格式 容器
SpringMVC运行流程分析之核心流程
SpringMVC运行流程分析之核心流程
17 0
|
2月前
|
移动开发 小程序 数据管理
9月开发者日回顾|小程序跳转接口等多个JSAPI更新,能力集成提供场景化排查工具
9月开发者日回顾|小程序跳转接口等多个JSAPI更新,能力集成提供场景化排查工具
27 0
|
4月前
|
内存技术
SpringMVC运行流程分析之前置流程
SpringMVC运行流程分析之前置流程
26 0
|
5月前
|
运维 监控 测试技术
Optimism(OP链)公链智能合约系统开发详细介绍丨案例设计丨功能逻辑丨需求步骤丨源码程序
Optimism(OP链)是一种二级扩展解决方案,旨在构建可扩展、低费用的区块链应用。
|
前端开发
前端学习案例5-执行机制1
前端学习案例5-执行机制1
62 0
前端学习案例5-执行机制1
|
前端开发
前端学习案例6-执行机制2
前端学习案例6-执行机制2
43 0
前端学习案例6-执行机制2
|
BI 数据处理 Scala
报表统计_执行框架_旧模块改造 | 学习笔记
快速学习报表统计_执行框架_旧模块改造
78 0
报表统计_执行框架_旧模块改造 | 学习笔记
|
前端开发
前端项目实战45-加一层判断 否则影响项目执行
前端项目实战45-加一层判断 否则影响项目执行
47 0

热门文章

最新文章