Project: containerd (Runtime / Container Runtime)
File: 2017-03-17.md

Thanks to @gianarb for starting the discussion around a test and CI plan for containerd. We want to make sure that users of containerd can feel secure depending on containerd; having a solid test plan is a must. Testing a project like containerd is always a challenge because of the systems that it needs to support. ARM, Windows, Linux, and Power (as well as many more variations) are all examples of platforms that we support today and will need a CI. You can view the issue and contribute to the testing plan . Work has started on porting over the Windows execution code. There is still a lot of testing to do after the port but a PR should be coming soon. We started the work to get container level metrics exported over prometheus. You can see the initial output here: ``` containerdcontainerblkioioservicebytesrecursive_bytes{id="test",major="8",minor="0",op="Async"} 958464 containerdcontainerblkioioservicebytesrecursive_bytes{id="test",major="8",minor="0",op="Read"} 958464 containerdcontainerblkioioservicebytesrecursive_bytes{id="test",major="8",minor="0",op="Sync"} 0 containerdcontainerblkioioservicebytesrecursive_bytes{id="test",major="8",minor="0",op="Total"} 958464 containerdcontainerblkioioservicebytesrecursive_bytes{id="test",major="8",minor="0",op="Write"} 0 containerdcontainerblkioioservicedrecursivetotal{id="test",major="8",minor="0",op="Async"} 17 containerdcontainerblkioioservicedrecursivetotal{id="test",major="8",minor="0",op="Read"} 17 containerdcontainerblkioioservicedrecursivetotal{id="test",major="8",minor="0",op="Sync"} 0 containerdcontainerblkioioservicedrecursivetotal{id="test",major="8",minor="0",op="Total"} 17 containerdcontainerblkioioservicedrecursivetotal{id="test",major="8",minor="0",op="Write"} 0 containerdcontainercpukernelnanoseconds{id="test"} 1e+07 containerdcontainercputhrottleperiods_total{id="test"} 0 containerdcontainercputhrottledperiods_total{id="test"} 0 containerdcontainercputhrottledtime_nanoseconds{id="test"} 0 containerdcontainercputotalnanoseconds{id="test"} 2.1428791e+07 containerdcontainercpuusernanoseconds{id="test"} 0 containerdcontainerhugetlbfailcnttotal{id="test",page="1GB"} 0 containerdcontainerhugetlbfailcnttotal{id="test",page="2MB"} 0 containerdcontainerhugetlbmaxbytes{id="test",page="1GB"} 0 containerdcontainerhugetlbmaxbytes{id="test",page="2MB"} 0 containerdcontainerhugetlbusagebytes{id="test",page="1GB"} 0 containerdcontainerhugetlbusagebytes{id="test",page="2MB"} 0 containerdcontainermemoryactiveanon_bytes{id="test"} 0 containerdcontainermemoryactivefile_bytes{id="test"} 659456 containerdcontainermemorycachebytes{id="test"} 925696 containerdcontainermemorydirtybytes{id="test"} 0 containerdcontainermemoryhierarchicalmemorylimitbytes{id="test"} 9.223372036854772e+18 containerdcontainermemoryhierarchicalmemswlimitbytes{id="test"} 9.223372036854772e+18 containerdcontainermemoryinactiveanon_bytes{id="test"} 73728 containerdcontainermemoryinactivefile_bytes{id="test"} 266240 containerdcontainermemorykernelfailcnt_total{id="test"} 0 containerdcontainermemorykernellimit_bytes{id="test"} 9.223372036854772e+18 containerdcontainermemorykernelmax_bytes{id="test"} 0 containerdcontainermemorykernelusage_bytes{id="test"} 0 containerdcontainermemorykerneltcpfailcnt_total{id="test"} 0 containerdcontainermemorykerneltcplimit_bytes{id="test"} 9.223372036854772e+18 containerdcontainermemorykerneltcpmax_bytes{id="test"} 0 containerdcontainermemorykerneltcpusage_bytes{id="test"} 0 containerdcontainermemorymappedfile_bytes{id="test"} 577536 containerdcontainermemoryoomtotal{id="test"} 0I containerdcontainermemorypgfaultbytes{id="test"} 770 containerdcontainermemorypgmajfaultbytes{id="test"} 6 containerdcontainermemorypgpginbytes{id="test"} 651 containerdcontainermemorypgpgoutbytes{id="test"} 407 containerdcontainermemoryrssbytes{id="test"} 73728 containerdcontainermemoryrsshuge_bytes{id="test"} 0 containerdcontainermemoryswapfailcnt_total{id="test"} 0 containerdcontainermemoryswaplimit_bytes{id="test"} 9.223372036854772e+18 containerdcontainermemoryswapmax_bytes{id="test"} 1.527808e+06 containerdcontainermemoryswapusage_bytes{id="test"} 999424 containerdcontainermemorytotalactiveanonbytes{id="test"} 0 containerdcontainermemorytotalactivefilebytes{id="test"} 659456 containerdcontainermemorytotalcache_bytes{id="test"} 925696 containerdcontainermemorytotaldirty_bytes{id="test"} 0 containerdcontainermemorytotalinactiveanonbytes{id="test"} 73728 containerdcontainermemorytotalinactivefilebytes{id="test"} 266240 containerdcontainermemorytotalmappedfilebytes{id="test"} 577536 containerdcontainermemorytotalpgfault_bytes{id="test"} 770 containerdcontainermemorytotalpgmajfault_bytes{id="test"} 6 containerdcontainermemorytotalpgpgin_bytes{id="test"} 651 containerdcontainermemorytotalpgpgout_bytes{id="test"} 407 containerdcontainermemorytotalrss_bytes{id="test"} 73728 containerdcontainermemorytotalrsshugebytes{id="test"} 0 containerdcontainermemorytotalunevictable_bytes{id="test"} 0 containerdcontainermemorytotalwriteback_bytes{id="test"} 0 containerdcontainermemoryunevictablebytes{id="test"} 0 containerdcontainermemoryusagefailcnt_total{id="test"} 0 containerdcontainermemoryusagelimit_bytes{id="test"} 9.223372036854772e+18 containerdcontainermemoryusagemax_bytes{id="test"} 1.527808e+06 containerdcontainermemoryusageusage_bytes{id="test"} 999424 containerdcontainermemorywritebackbytes{id="test"} 0 containerdcontainerpercpunanoseconds{cpu="0",id="test"} 7.530139e+06 containerdcontainerpercpunanoseconds{cpu="1",id="test"} 4.586408e+06 containerdcontainerpercpunanoseconds{cpu="2",id="test"} 5.076059e+06 containerdcontainerpercpunanoseconds{cpu="3",id="test"} 4.236185e+06 containerdcontainerpids_current{id="test"} 1 containerdcontainerpids_limit{id="test"} 0 ``` The `id` label will be the id of the container so users can filter on the metrics for only the containers that they care about. The frequency of metric collection is configurable via the prometheus scrape time. Every time the `/metrics` API is hit, that is when container metrics are collected. There is no internal timer in containerd, you only pay the cost of collecting metrics when you are asking for them. If you never ask for metrics the collection never happens. There should be a PR up soon so that we can discuss the metrics and label names. https://github.com/containerd/containerd/pull/640 We now have a proof of concept of end to end pull. Up to this point, the relationship between subsystems has been somewhat theoretical. We now leverage fetching, the snapshot drivers, the rootfs service, image metadata and the execution service, validating the proposed model for containerd. There are a few caveats, including the need to move some of the access into GRPC services, but the basic components are there. The first command we will cover here is `dist pull`. This is the analog of `docker pull` and `git pull`. It performs a full resource fetch for an image and unpacks the root filesystem into the snapshot drivers. An example follows: ``` console $ sudo ./bin/dist pull docker.io/library/redis:latest docker.io/library/redis:latest: resolved |++++++++++++++++++++++++++++++++++++++| manifest-sha256:4c8fb09e8d634ab823b1c125e64f0e1ceaf216025aa38283ea1b42997f1e8059: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:3b281f2bcae3b25c701d53a219924fffe79bdb74385340b73a539ed4020999c4: done |++++++++++++++++++++++++++++++++++++++| config-sha256:e4a35914679d05d25e2fccfd310fde1aa59ffbbf1b0b9d36f7b03db5ca0311b0: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:4b7726832aec75f0a742266c7190c4d2217492722dfd603406208eaa902648d8: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:338a7133395941c85087522582af182d2f6477dbf54ba769cb24ec4fd91d728f: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:83f12ff60ff1132d1e59845e26c41968406b4176c1a85a50506c954696b21570: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:693502eb7dfbc6b94964ae66ebc72d3e32facd981c72995b09794f1e87bac184: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:622732cddc347afc9360b4b04b46c6f758191a1dc73d007f95548658847ee67e: done |++++++++++++++++++++++++++++++++++++++| layer-sha256:19a7e34366a6f558336c364693df538c38307484b729a36fede76432789f084f: done |++++++++++++++++++++++++++++++++++++++| elapsed:

s total: 0.0 B (0.0 B/s) INFO[0001] unpacking rootfs ``` Note that we haven't integrated rootfs unpacking into the status output, but we pretty much have what is in docker today (:P). We can see the result of our pull with the following: ```console $ sudo ./bin/dist images REF TYPE DIGEST SIZE docker.io/library/redis:latest application/vnd.docker.distribution.manifest.v2+json sha256:4c8fb09e8d634ab823b1c125e64f0e1ceaf216025aa38283ea1b42997f1e8059 1.8 kB ``` The above shows that we have an image called "docker.io/library/redis:latest" mapped to the given digest marked with a specific format. We get the size of the manifest right now, not the full image, but we can add more as we need it. For the most part, this is all that is needed, but a few tweaks to the model for naming may need to be added. Specifically, we may want to index under a few different names, including those qualified by hash or matched by tag versions. We can do more work in this area as we develop the metadata store. The name shown above can then be used to run the actual container image. We can do this with the following command: ```console $ sudo ./bin/ctr run --id foo docker.io/library/redis:latest /usr/local/bin/redis-server 1:C 17 Mar 17:20:25.316 # Warning: no config file specified, using the default config. In order to specify a config file use /usr/local/bin/redis-server /path/to/redis.conf 1:M 17 Mar 17:20:25.317 * Increased maximum number of open files to 10032 (it was originally set to 1024). . .-`` ''-. .-`` `. `. ''-._ Redis 3.2.8 (00000000/0) 64 bit .-`` .-```. ```\/ ., ''-._ ( ' , .-` | `, ) Running in standalone mode |`-.`-...-` ...-.``-.|'` _.-'| Port: 6379 | `-. `. / _.-' | PID: 1 `-. `-. `-./ .-' .-' |`-.`-. `-..-' .-'.-'| | `-.`-. .-'.-' | http://redis.io `-. `-.`-..-'.-' .-' |`-.`-. `-..-' .-'.-'| | `-.`-. .-'.-' | `-. `-.`-..-'.-' .-' `-. `-..-' .-' `-. .-' `-..-' 1:M 17 Mar 17:20:25.326 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 17 Mar 17:20:25.326 # Server started, Redis version 3.2.8 1:M 17 Mar 17:20:25.326 # WARNING overcommitmemory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommitmemory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 1:M 17 Mar 17:20:25.326 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 1:M 17 Mar 17:20:25.326 * The server is now ready to accept connections on port 6379 ``` Wow! So, now we are running `redis`! There are still a few things to work out. Notice that we have to specify the command as part of the arguments to `ctr run`. This is because are not yet reading the image config and converting it to an OCI runtime config. With the base laid in this PR, adding such functionality should be straightforward. While this is a little messy, this is great progress. It should be easy sailing from here.