Skip to content

Config Merges For Plugins Panic #5808

@isugimpy

Description

@isugimpy

Description

When importing a config which includes configuration of the io.containerd.grpc.v1.cri plugin, the merge fails and a panic occurs.

Steps to reproduce the issue:

  1. Create /etc/containerd/config.toml containing
version = 2
imports = ["/etc/containerd/panic.toml"]

[plugins]
  [plugins."io.containerd.grpc.v1.cri"]
    disable_apparmor = false
  1. Create /etc/containerd/panic.toml containing
version = 2

[plugins]
  [plugins."io.containerd.grpc.v1.cri"]
    disable_apparmor = true
  1. Run containerd config dump

Describe the results you received:

# containerd config dump
panic: reflect: reflect.flag.mustBeAssignable using unaddressable value

goroutine 1 [running]:
reflect.flag.mustBeAssignableSlow(0x99)
        /usr/lib/go-1.13/src/reflect/value.go:247 +0x13a
reflect.flag.mustBeAssignable(...)
        /usr/lib/go-1.13/src/reflect/value.go:234
reflect.Value.Set(0x5650669832e0, 0xc000491230, 0x99, 0x5650669832e0, 0xc000491200, 0x99)
        /usr/lib/go-1.13/src/reflect/value.go:1531 +0x3d
github.com/containerd/containerd/vendor/github.com/imdario/mergo.deepMerge(0x5650669832e0, 0xc000491230, 0x99, 0x5650669832e0, 0xc000491200, 0x99, 0xc0001f0250, 0x2, 0xc00049d020, 0x0, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/imdario/mergo/merge.go:99 +0x3355
github.com/containerd/containerd/vendor/github.com/imdario/mergo.deepMerge(0x56506683e3e0, 0xc000335b40, 0x195, 0x56506683e3e0, 0xc0004982e0, 0x195, 0xc0001f0250, 0x1, 0xc00049d020, 0x0, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/imdario/mergo/merge.go:147 +0xa96
github.com/containerd/containerd/vendor/github.com/imdario/mergo.deepMerge(0x565066a5cd60, 0xc000335a00, 0x199, 0x565066a5cd60, 0xc0004981a0, 0x199, 0xc0001f0250, 0x0, 0xc00049d020, 0x199, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/imdario/mergo/merge.go:93 +0x324b
github.com/containerd/containerd/vendor/github.com/imdario/mergo.merge(0x5650668bf7e0, 0xc000335a00, 0x5650668bf7e0, 0xc0004981a0, 0xc0001f0398, 0x2, 0x2, 0x565066a5cd60, 0x1)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/imdario/mergo/merge.go:361 +0x32c
github.com/containerd/containerd/vendor/github.com/imdario/mergo.Merge(...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/imdario/mergo/merge.go:291
github.com/containerd/containerd/services/server/config.mergeConfig(0xc000335a00, 0xc0004981a0, 0xc0004981a0, 0x0)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/services/server/config/config.go:325 +0xa2
github.com/containerd/containerd/services/server/config.LoadConfig(0xc000421260, 0x24, 0xc000335a00, 0xc0003dbd20, 0x1b)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/services/server/config/config.go:245 +0x1fc
github.com/containerd/containerd/cmd/containerd/command.glob..func2(0xc000357080, 0x0, 0xc000423af0)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/cmd/containerd/command/config.go:111 +0x77
github.com/containerd/containerd/vendor/github.com/urfave/cli.HandleAction(0x5650667f6740, 0x565066a92578, 0xc000357080, 0xc000357080, 0x0)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/app.go:523 +0xc0
github.com/containerd/containerd/vendor/github.com/urfave/cli.Command.Run(0x565065fa71e0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x56506601fc8b, 0x48, 0x0, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/command.go:174 +0x51e
github.com/containerd/containerd/vendor/github.com/urfave/cli.(*App).RunAsSubcommand(0xc000329a40, 0xc000356dc0, 0x0, 0x0)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/app.go:404 +0x86b
github.com/containerd/containerd/vendor/github.com/urfave/cli.Command.startApp(0x565065fa94d3, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x565065fe134e, 0x24, 0x0, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/command.go:329 +0x847
github.com/containerd/containerd/vendor/github.com/urfave/cli.Command.Run(0x565065fa94d3, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x565065fe134e, 0x24, 0x0, ...)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/command.go:102 +0x9cc
github.com/containerd/containerd/vendor/github.com/urfave/cli.(*App).Run(0xc000329880, 0xc00003c090, 0x3, 0x3, 0x0, 0x0)
        /build/containerd-xfqmW9/containerd-1.5.2/.gopath/src/github.com/containerd/containerd/vendor/github.com/urfave/cli/app.go:276 +0x71a
main.main()
        github.com/containerd/containerd/cmd/containerd/main.go:33 +0x51

Describe the results you expected:
An output config file which correctly contains disable_apparmor = true

What version of containerd are you using:

$ containerd --version
containerd github.com/containerd/containerd 1.5.2-0ubuntu1~18.04.2

Any other relevant information (runC version, CRI configuration, OS/Kernel version, etc.):
I've also tested this off the head of release/1.5. I can confirm that if mergo is updated to 0.3.12, this behavior does not occur, as I've made a custom build off of release/1.5 with the upgraded mergo and no crash occurs, and the output is working.

There may be a secondary issue here in how configuration merges occur, which I can submit as a separate issue if desired. The original thing I was attempting to do was have multiple imported config files which contain registry mirror endpoints individually. The expectation I had based on the text of https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md was that the array values for the endpoint field would be merged. Instead, they're being replaced. I don't believe this is an issue with mergo, but is rather a containerd issue. If maintainers would like me to open that as a separate issue, I can, but it isn't one that is exposed via the current version of mergo, so it won't be reproducible without fixing this issue first.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions