Skip to content

Conversation

misak113
Copy link
Contributor

@misak113 misak113 commented Nov 5, 2022

in practice, the missing service name in extended configuration means that nothing is extended

current state was that the docker-compose command fails with following error:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc0007c4230, 0x50}, {0xc000502880, 0x7}, 0xc0005fc720?, {0xc0007c4230, 0x40}, 0xc0004d22d0?, 0xc000480390, 0xc0007cb1f8)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:511 +0x6ab
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc0007b4780, 0x55}, {0xc000795e98, 0x7}, 0xc0005f3fb0?, {0xc0007b4780, 0x40}, 0xc00058c7e0?, 0xc000480390, 0xc0007cb1f8)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:539 +0x31a
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc000067180, 0x4f}, {0xc0001edac0, 0x7}, 0x4156d0?, {0xc000067180, 0x40}, 0x7fb739ec2fff?, 0xc000480390, 0xc0007cb1f8)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:539 +0x31a
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc0000665f0, 0x4c}, {0xc0002b4090, 0x7}, 0x0?, {0xc0000665f0, 0x39}, 0x203000?, 0xc000480390, 0xc0007cb1f8)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:539 +0x31a
github.com/compose-spec/compose-go/loader.LoadServices({0xc0000665f0, 0x4c}, 0x1d97a32?, {0xc0000665f0, 0x39}, 0xc000669850?, 0xa86b35?)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:490 +0x1d1
github.com/compose-spec/compose-go/loader.loadSections({0xc0000665f0, 0x4c}, 0x202ec0?, {{0x0, 0x0}, {0xc0000665f0, 0x39}, {0xc0004802d0, 0x1, 0x1}, ...}, ...)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:314 +0x2cb
github.com/compose-spec/compose-go/loader.Load({{0x0, 0x0}, {0xc0000665f0, 0x39}, {0xc0004802d0, 0x1, 0x1}, 0xc000480360}, {0xc00041c480, 0x6, ...})
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:187 +0x892
github.com/compose-spec/compose-go/cli.ProjectFromOptions(0xc000498230)
        github.com/compose-spec/compose-go@v1.6.0/cli/options.go:358 +0x2e9
github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProject(0xc000393700, {0x2f24c78, 0x0, 0x0}, {0xc000867960?, 0x8?, 0x0?})
        github.com/docker/compose/v2/cmd/compose/compose.go:185 +0x10f
github.com/docker/compose/v2/cmd/compose.runConvert({0x20a23a0?, 0xc00041c640}, {0x20b7578, 0xc0003bc0e0}, {0xc000393700, {0x1d91e19, 0x4}, {0x0, 0x0}, 0x0, ...}, ...)
        github.com/docker/compose/v2/cmd/compose/convert.go:117 +0x16a
github.com/docker/compose/v2/cmd/compose.convertCommand.func2({0x20a23a0?, 0xc00041c640?}, {0x2f24c78?, 0xc0000061a0?, 0x18bdcba?})
        github.com/docker/compose/v2/cmd/compose/convert.go:94 +0xdc
github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x20a23a0?, 0xc00041c640?}, 0x2?, {0x2f24c78?, 0x1?, 0x0?})
        github.com/docker/compose/v2/cmd/compose/compose.go:90 +0x36
github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc0001d0000, {0x2f24c78, 0x0, 0x0})
        github.com/docker/compose/v2/cmd/compose/compose.go:69 +0x21c
github.com/spf13/cobra.(*Command).execute(0xc0001d0000, {0xc00027d5d0, 0x0, 0x0})
        github.com/spf13/cobra@v1.6.0/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc0003c5b00)
        github.com/spf13/cobra@v1.6.0/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.6.0/command.go:968
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc0002c8fc0?, 0xc0002d6300, {{0x1d92070, 0x5}, {0x1d9b150, 0xb}, {0x2081d28, 0x7}, {0x0, 0x0}, ...})
        github.com/docker/cli@v20.10.19+incompatible/cli-plugins/plugin/plugin.go:51 +0x130
github.com/docker/cli/cli-plugins/plugin.Run(0x1ea8680, {{0x1d92070, 0x5}, {0x1d9b150, 0xb}, {0x2081d28, 0x7}, {0x0, 0x0}, {0x0, ...}, ...})
        github.com/docker/cli@v20.10.19+incompatible/cli-plugins/plugin/plugin.go:64 +0xee
main.pluginMain()
        github.com/docker/compose/v2/cmd/main.go:36 +0xdf
main.main()
        github.com/docker/compose/v2/cmd/main.go:68 +0x198

@misak113 misak113 requested a review from ndeloof as a code owner November 5, 2022 21:42
@glours
Copy link
Collaborator

glours commented Nov 8, 2022

Hey @misak113,
Thanks for your contribution, is it possible to give us a way to reproduce the issue?
I just want to be sure we'll fix the root cause and not just a side effect

@misak113
Copy link
Contributor Author

misak113 commented Dec 21, 2022

An example of not working configuration is here:

  • file docker-compose.yml:
services:
  app1:
    image: alpine
    command: ["sleep", "1000"]
    extends:
      file: parent.yml
      service: app1
  • file parant.yml:
services:
  app1:
#  app1: {}

The following command:

docker-compose up -d

Is failing with error:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc00017a5a0, 0x4a}, {0xc0005eafd8, 0x4}, 0x2?, {0xc00017a5a0, 0x3f}, 0x0?, 0xc000162690, 0xc0002af308)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:511 +0x6ab
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc00017c5a0, 0x52}, {0xc000404310, 0x4}, 0x0?, {0xc00017c5a0, 0x3f}, 0x203000?, 0xc000162690, 0xc0002af308)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:539 +0x31a
github.com/compose-spec/compose-go/loader.LoadServices({0xc00017c5a0, 0x52}, 0xc0002afa38?, {0xc00017c5a0, 0x3f}, 0xc0002af960?, 0xa86b35?)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:490 +0x1d1
github.com/compose-spec/compose-go/loader.loadSections({0xc00017c5a0, 0x52}, 0x4d92b1?, {{0x0, 0x0}, {0xc00017c5a0, 0x3f}, {0xc000162660, 0x1, 0x1}, ...}, ...)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:314 +0x2cb
github.com/compose-spec/compose-go/loader.Load({{0x0, 0x0}, {0xc00017c5a0, 0x3f}, {0xc000162660, 0x1, 0x1}, 0xc0001623f0}, {0xc0001661c8, 0x3, ...})
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:187 +0x892
github.com/compose-spec/compose-go/cli.ProjectFromOptions(0xc0003921c0)
        github.com/compose-spec/compose-go@v1.6.0/cli/options.go:358 +0x2e9
github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProject(0xc000505000, {0xc0001b9830, 0x0, 0x1}, {0xc00058ba00?, 0x18?, 0x7f7a4c3225b8?})
        github.com/docker/compose/v2/cmd/compose/compose.go:185 +0x10f
github.com/docker/compose/v2/cmd/compose.(*projectOptions).WithServices.func1({0x20a23a0, 0xc0000b6240}, {0xc0001b9830, 0x0, 0x1})
        github.com/docker/compose/v2/cmd/compose/compose.go:120 +0x98
github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x20a23a0?, 0xc0000b6240?}, 0x2?, {0xc0001b9830?, 0x1?, 0x0?})
        github.com/docker/compose/v2/cmd/compose/compose.go:90 +0x36
github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc00046c600, {0xc0001b9830, 0x0, 0x1})
        github.com/docker/compose/v2/cmd/compose/compose.go:69 +0x21c
github.com/spf13/cobra.(*Command).execute(0xc00046c600, {0xc0003350d0, 0x1, 0x1})
        github.com/spf13/cobra@v1.6.0/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000031500)
        github.com/spf13/cobra@v1.6.0/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.6.0/command.go:968
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc00045a8c0?, 0xc00046c300, {{0x1d92070, 0x5}, {0x1d9b150, 0xb}, {0x2081d28, 0x7}, {0x0, 0x0}, ...})
        github.com/docker/cli@v20.10.19+incompatible/cli-plugins/plugin/plugin.go:51 +0x130
github.com/docker/cli/cli-plugins/plugin.Run(0x1ea8680, {{0x1d92070, 0x5}, {0x1d9b150, 0xb}, {0x2081d28, 0x7}, {0x0, 0x0}, {0x0, ...}, ...})
        github.com/docker/cli@v20.10.19+incompatible/cli-plugins/plugin/plugin.go:64 +0xee
main.pluginMain()
        github.com/docker/compose/v2/cmd/main.go:36 +0xdf
main.main()
        github.com/docker/compose/v2/cmd/main.go:68 +0x198

If you add empty object {} into parent.yml as commented out in the example, it starts working.


It can be fixed with my fix here or either the more suitable error message like following:

cannot extend service "app1" in /mnt/data/home/misak113/dev/signageos/tmp/docker-componse-issue/parent.yml: service has to be object

The other option to fix this:

return nil, fmt.Errorf("cannot extend service %q in %s: service has to be object", name, filename)

@ndeloof
Copy link
Collaborator

ndeloof commented Jan 3, 2023

LGTM, but for opensource contributions we require all commit to be signed-off
please amend your commit (git commit --amend --signoff) then push --force your branch

@misak113 misak113 force-pushed the mz/fix-nil-extend branch 2 times, most recently from 5aab1ae to 6bc67ca Compare January 3, 2023 10:11
in practice, the missing service name in extended configuration means that nothing is extended
current state was that the docker-compose command fails with following error:
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc0007c4230, 0x50}, {0xc000502880, 0x7}, 0xc0005fc720?, {0xc0007c4230, 0x40}, 0xc0004d22d0?, 0xc000480390, 0xc0007cb1f8)
        github.com/compose-spec/compose-go@v1.6.0/loader/loader.go:511 +0x6ab

Signed-off-by: Michael Zabka <zabka.michael+scarlett@gmail.com>
@ndeloof ndeloof merged commit 559e4fd into compose-spec:master Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants