Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Adding networks: to docker-compose.yaml file results in a runtime error #474

Closed
peterpme opened this issue Mar 7, 2017 · 17 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug. libcompose

Comments

@peterpme
Copy link

peterpme commented Mar 7, 2017

kompose version 0.3.0 (135165b3)
go version go1.8 darwin/amd64

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x21eda6c]

goroutine 1 [running]:
github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project.(*Project).handleNetworkConfig(0xc42031c0e0)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project/project.go:281 +0x19c
github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project.(*Project).load(0xc42031c0e0, 0x7fff5fbff5bb, 0x1a, 0xc42041c400, 0x69a, 0x89a, 0xc4200aa990, 0xc4204c9410)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project/project.go:234 +0x490
github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project.(*Project).Parse(0xc42031c0e0, 0x0, 0x0)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/docker/libcompose/project/project.go:112 +0x162
github.com/kubernetes-incubator/kompose/pkg/loader/compose.(*Compose).LoadFile(0x365d9b0, 0xc420293480, 0x1, 0x1, 0xc4200aa8d0, 0x0, 0x10)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/pkg/loader/compose/compose.go:304 +0x10f
github.com/kubernetes-incubator/kompose/pkg/app.Convert(0x100000100, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xc420293480, 0x1, 0x1, ...)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/pkg/app/app.go:214 +0x145
github.com/kubernetes-incubator/kompose/cmd.glob..func3(0x362fb00, 0xc420284fc0, 0x0, 0x2)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/cmd/convert.go:85 +0x4f
github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra.(*Command).execute(0x362fb00, 0xc420284e20, 0x2, 0x2, 0x362fb00, 0xc420284e20)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra/command.go:650 +0x231
github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x362ff40, 0xc42006e058, 0x0, 0xc4204c9f48)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra/command.go:737 +0x339
github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra.(*Command).Execute(0x362ff40, 0x1, 0x1)
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/vendor/github.com/spf13/cobra/command.go:695 +0x2b
github.com/kubernetes-incubator/kompose/cmd.Execute()
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/cmd/root.go:92 +0x31
main.main()
	/home/tomas/dev/go/src/github.com/kubernetes-incubator/kompose/main.go:22 +0x20
@cdrage
Copy link
Member

cdrage commented Mar 8, 2017

Uh oh, that doesn't look right. what commands did you use / docker-compose file to get this error? @peterpme

@peterpme
Copy link
Author

peterpme commented Mar 8, 2017

Hey @cdrage thanks for the quick response!

I ran kompose -f docker-compose-staging.yml convert

@surajssd
Copy link
Member

surajssd commented Mar 8, 2017

this seems to be coming from libcompose, and would like more info on this about how does the docker-compose file looks like?

@peterpme do you mind sharing docker-compose file?

@peterpme
Copy link
Author

peterpme commented Mar 8, 2017

@surajssd thanks for the quick response! Absolutely, if you could help me get this onto GCloud / Kubernetes I'd be very happy :)

It's an nginx reverse proxy splitting 3 different apps. Nginx handles SSL too.

docker-compose-staging.yml:

  • cms (/|blog|about-us|contact-us)
  • api /api
  • search /search
version: '2'

services:
  nginx:
    image: peterpme/nginx
    container_name: nginx
    networks:
      - peterpme-infra
    ports:
      - "80:80"
      - "443:443"
    environment:
      - CERTS=www.peterp.me
      - EMAIL=peter@peterp.me
    volumes:
      - /etc/ssl/dhparam:/etc/ssl/dhparam
      - /srv/letsencrypt:/etc/letsencrypt
  cms:
    image: peterpme/cms
    container_name: cms
    environment:
      - NPM_TOKEN
      - NODE_ENV=production
      - PORT=5000
      - MONGODB_URI=
      - CLOUDINARY_URL=
      - COOKIE_SECRET=
      - NEW_RELIC_ENABLED=false
    networks:
      - peterpme-infra
  search:
    image: peterpme/search
    container_name: search
    environment:
      - NPM_TOKEN
      - NODE_ENV=production
      - APP_ENV=
      - PORT=5000
      - GOOGLE_PLACES_API_KEY=
      - NEW_RELIC_ENABLED=false
    networks:
      - peterpme-infra
  api:
    image: peterpme/api-next
    container_name: api
    environment:
      - NPM_TOKEN
      - NODE_ENV=production
      - DB_CONNECTION_STRING=
      - MAILCHIMP_API_KEY=
      - NEW_RELIC_ENABLED=false
    networks:
      - peterpme-infra

networks:
  peterpme-infra:

Thank you!

@cdrage
Copy link
Member

cdrage commented Mar 8, 2017

Hey @peterpme

It's

networks:
  peterpme-infra:

That's somehow screwing it up, just remove those two lines and it'll convert fine. I'll open up another issue for this, these panics shouldn't be happening.

Thanks for opening up this issue and let us know if there is anything else we can do to help!

@cdrage cdrage closed this as completed Mar 8, 2017
@peterpme
Copy link
Author

peterpme commented Mar 8, 2017

Hey @cdrage thanks! Will there be any implications on my end if I remove networks? Will the containers still be able to communicate with nginx?

@cdrage
Copy link
Member

cdrage commented Mar 8, 2017

@peterpme Since Kubernetes is a flat-design in terms of network (there's no segregation of networks) any container created will be able to communicate to the other one.

The objective is to get you started with Kubernetes. Since your docker-compose file is quite complex ,it may take some modifications to get it running (the first being persistent volumes would need to be created!)

@cdrage
Copy link
Member

cdrage commented Mar 8, 2017

Hey @peterme, I'm going to leave this issue open and simply rename the title :) Better to keep the context in here rather than another issue.

@cdrage cdrage reopened this Mar 8, 2017
@cdrage cdrage changed the title 0.3.0 (135165b3) panic: runtime error: invalid memory address or nil pointer dereference Bug: Adding networks: to docker-compose.yaml file results in a runtime error Mar 8, 2017
@cdrage cdrage added the kind/bug Categorizes issue or PR as related to a bug. label Mar 8, 2017
@surajnarwade
Copy link
Contributor

@surajssd @peterpme , kompose doesn't support networks key yet.
for reference

@cdrage
Copy link
Member

cdrage commented Mar 9, 2017

@surajnarwade Yes. The problem here is that this panics, so some investigation is required. I have a feeling it's because it's trying to parse:

networks:
  peterpme-infra:

and it's coming up as incorrect yaml.

@surajnarwade
Copy link
Contributor

@cdrage 👍

@surajnarwade
Copy link
Contributor

surajnarwade commented Mar 22, 2017

@cdrage @peterpme , I tried out above example and checked with https://docs.docker.com/compose/networking/ and its working in following cases:

as peterpme-infra is present in all services, assuming that it's default network

networks:
     default:
             name: peterpme-infra

or if it is pre existing network:

networks:
     default:
         external:
             name: peterpme-infra

or if its not a default network, then mention network driver as below:

networks:
    peterpme-infra:
            driver: custom-driver

@kadel
Copy link
Member

kadel commented Mar 22, 2017

It looks like this is bug in libcompose.

version: '2' 
services:
  foo:
    image: busybox
    networks:
        - foo
networks:
    foo:

works with docker-compose:

▶ docker-compose up     
Creating kompose_foo_1
Attaching to kompose_foo_1
kompose_foo_1 exited with code 0

but fails with libcompose:

▶ libcompose-cli_linux-amd64 up
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4d8738]

goroutine 1 [running]:
panic(0x868ac0, 0xc420010110)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/docker/libcompose/vendor/github.com/urfave/cli.HandleAction.func1(0xc420181cc8)
	/go/src/github.com/docker/libcompose/vendor/github.com/urfave/cli/app.go:472 +0x29e
panic(0x868ac0, 0xc420010110)
	/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/docker/libcompose/project.(*Project).handleNetworkConfig(0xc420082620)
	/go/src/github.com/docker/libcompose/project/project.go:281 +0x1a8
github.com/docker/libcompose/project.(*Project).load(0xc420082620, 0x8f035e, 0x12, 0xc42028d400, 0x61, 0x261, 0xc420181620, 0x410c78)
	/go/src/github.com/docker/libcompose/project/project.go:234 +0x38f
github.com/docker/libcompose/project.(*Project).Parse(0xc420082620, 0xb18e40, 0xc4202f2200)
	/go/src/github.com/docker/libcompose/project/project.go:112 +0x15a
github.com/docker/libcompose/docker.NewProject(0xc4200c2870, 0x0, 0x0, 0x0, 0x18, 0xc420181810)
	/go/src/github.com/docker/libcompose/docker/project.go:58 +0x106
github.com/docker/libcompose/cli/docker/app.(*ProjectFactory).Create(0xb66c60, 0xc4202b6500, 0x0, 0x8, 0x8, 0xc4202c4b80)
	/go/src/github.com/docker/libcompose/cli/docker/app/factory.go:20 +0xae
github.com/docker/libcompose/cli/app.WithProject.func1(0xc4202b6500, 0x0, 0x0)
	/go/src/github.com/docker/libcompose/cli/app/app.go:45 +0x4e
reflect.Value.call(0x84d260, 0xc4202c4220, 0x13, 0x8e9d90, 0x4, 0xc420181c68, 0x1, 0x1, 0x4702f8, 0x8dbe60, ...)
	/usr/local/go/src/reflect/value.go:434 +0x5c8
reflect.Value.Call(0x84d260, 0xc4202c4220, 0x13, 0xc420181c68, 0x1, 0x1, 0x0, 0x140, 0x140)
	/usr/local/go/src/reflect/value.go:302 +0xa4
github.com/docker/libcompose/vendor/github.com/urfave/cli.HandleAction(0x84d260, 0xc4202c4220, 0xc4202b6500, 0x0, 0x0)
	/go/src/github.com/docker/libcompose/vendor/github.com/urfave/cli/app.go:481 +0x1e0
github.com/docker/libcompose/vendor/github.com/urfave/cli.Command.Run(0x8e9974, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8f1b92, 0x15, 0x0, ...)
	/go/src/github.com/docker/libcompose/vendor/github.com/urfave/cli/command.go:186 +0xc26
github.com/docker/libcompose/vendor/github.com/urfave/cli.(*App).Run(0xc4202a4180, 0xc42000a3c0, 0x2, 0x2, 0x0, 0x0)
	/go/src/github.com/docker/libcompose/vendor/github.com/urfave/cli/app.go:235 +0x60c
main.main()
	/go/src/github.com/docker/libcompose/cli/main/main.go:75 +0x16d4

@surajnarwade
Copy link
Contributor

surajnarwade commented Mar 23, 2017

@kadel , I have opened an issue regarding this in libcompose, which can be tracked here, docker/libcompose#456

@surajnarwade
Copy link
Contributor

@kadel, @cdrage I have sent PR for this issue in libcompose, which can be tracked here, docker/libcompose#467

surajnarwade added a commit to surajnarwade/kompose that referenced this issue May 15, 2017
It resolves issues kubernetes#474 and kubernetes#589 which were coming from libcompose,
as well as resolves kubernetes#440 and kubernetes#437 partially as `group_add` & `stop_grace_period`
are supported by libcompose now.
@surajnarwade
Copy link
Contributor

surajnarwade commented May 15, 2017

@peterpme @kadel @cdrage ,

I tried above docker compose file, its working well now,

$ kompose convert -f docker-compose.yml 
WARN Unsupported root level networks key - ignoring 
WARN Unsupported networks key - ignoring          
WARN Volume mount on the host "/etc/ssl/dhparam" isn't supported - ignoring path on the host 
WARN Volume mount on the host "/srv/letsencrypt" isn't supported - ignoring path on the host 
INFO file "api-service.yaml" created              
INFO file "cms-service.yaml" created              
INFO file "nginx-service.yaml" created            
INFO file "search-service.yaml" created           
INFO file "api-deployment.yaml" created           
INFO file "cms-deployment.yaml" created           
INFO file "nginx-deployment.yaml" created         
INFO file "nginx-claim0-persistentvolumeclaim.yaml" created 
INFO file "nginx-claim1-persistentvolumeclaim.yaml" created 
INFO file "search-deployment.yaml" created

we can close this issue now

cdrage pushed a commit to cdrage/kompose that referenced this issue May 17, 2017
It resolves issues kubernetes#474 and kubernetes#589 which were coming from libcompose,
as well as resolves kubernetes#440 and kubernetes#437 partially as `group_add` & `stop_grace_period`
are supported by libcompose now.
@surajnarwade
Copy link
Contributor

@cdrage @surajssd , we can close this now

@cdrage cdrage closed this as completed May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. libcompose
Projects
None yet
Development

No branches or pull requests

5 participants