JSON Unmarshaling error when using external links & rancher-compose

Hello everyone, ran into a weird issue with rancher-compose when i’m trying to use cross-stack linking.

In my default stack (which has been renamed to ‘Main’), I have a database. I have an image in another stack that will be linking to that database.

This is the docker compose file Im using:

wordpress:

  image: 192.168.201.110:5000/wrl/nginx-php-cache:latest
  expose:
    - "80"
  restart: always
  links:
    - memcached
  external_links:
    - Main/MariaDB:mysql
  volumes:
    - /sites/prod/wrladv.com/current/app:/var/www/app:rw
  entrypoint: /sbin/my_init
memcached:
  image: memcached:latest
  restart: always
  mem_limit: 128000000
  expose:
    - "11211"

This is the error it gives:

ERRO[0002] Failed Starting wordpress : json: cannot unmarshal number into Go value of type string 
ERRO[0002] Failed to start: wordpress : json: cannot unmarshal number into Go value of type string 
FATA[0002] json: cannot unmarshal number into Go value of type string 

If I remove the external link and use rancher-compose it starts up fine. Then I can add the external link through the UI to get it to work. Anybody know why it is giving me the marshaling error?

This is a quoted vs unquoted issue. Probably the value of mem_limit that needs to be a string value… so try wrapping the 128000000 in quotes…

If that doesn’t help, look for other numbers (possibly in quotes) and add (or remove) the quotes to see if it helps.

I originally thought it was an issue needing quotes, but it’s not. I’ve tried quoting all numbers, but that doesn’t help. It ONLY occurs when I have the external_links defined, and it also doesn’t occur right away. It will try to start the services but around 10 seconds into the process is when it fails. Normally when the YAML is messed up rancher-compose won’t even run. If I remove the external_links definition it has no issues and sets the mem_limit correctly using the integer.

I’m pretty sure the unmarshaling error is occuring when it decodes a JSON response from the API server.

Well that is indeed weird. How’s the quoting in the Main stack?

The Main stack is the default stack created by Rancher, just renamed to Main. All of the services in that stack are created through the UI. I haven’t had any issues before with linking, and it only seems to happen with an external link. I did use the external_links feature correctly, right? I couldn’t find a ton of docs on it other than a mention in the load balancer section.

No, it looks right. Beats me, I’ll leave it for the experts :smile:

Alena, any idea why this is happening?

Is there an equivalent rancher-compose.yml and could I also get the docker-compose.yml for the Main stack? I will try to reproduce in the next day or two.

I didn’t use a rancher-compose file for the stack with wordpress. Also I don’t have a docker-compose file for Main stack, as I am not using rancher-compose for that stack.

No, I did not use a rancher-compose file for the stack with the external_links. As for the ‘Main’ stack I created that one through the UI so I do not have a docker-compose file for that stack.

If it’d help I can allow your github account to access my UI temporarily.

If you click on the stack name, there are a number of buttons, where the right-most one is to get the compose files for your stack.

Never noticed that before. Anyway here is the docker-compose file:

MainLB-SSL:
  ports:
  - 443:443
  - 80:80
  restart: always
  external_links:
  - hammond-dev-site/wordpress:wordpress
  - loveandrew-dev-wrlweb-com/wordpress:wordpress
  - nolan-dev-wrlweb-com/wordpress:wordpress
  - loveandrew-prod-site/wordpress:wordpress
  - wrl-wp-production/wordpress:wordpress
  - conceptservices-production/wordpress:wordpress
  - hammond-production-site/wordpress:wordpress
  labels:
    io.rancher.loadbalancer.target.ImageServer-Rhonda: images.dev.wrlweb.com
    io.rancher.loadbalancer.target.loveandrew-prod-site/wordpress: loveandrew.org,www.loveandrew.com
    io.rancher.scheduler.global: 'true'
    io.rancher.loadbalancer.ssl.ports: '443'
    io.rancher.loadbalancer.target.nolan-dev-wrlweb-com/wordpress: nolan.dev.wrlweb.com
    io.rancher.loadbalancer.target.hammond-dev-site/wordpress: hammond.dev.wrlweb.com
    io.rancher.loadbalancer.target.hammond-production-site/wordpress: hammondconstruction.com,www.hammondconstruction.com
    io.rancher.loadbalancer.target.wrl-wp-production/wordpress: wrladv.com,www.wrladv.com
    io.rancher.loadbalancer.target.conceptservices-production/wordpress: conceptservicesltd.com,www.conceptservicesltd.com,concept.dev.wrlweb.com
    io.rancher.loadbalancer.target.loveandrew-dev-wrlweb-com/wordpress: loveandrew.dev.wrlweb.com
    io.rancher.loadbalancer.target.PHPMyAdmin: phpmyadmin.dev.wrlweb.com
  tty: true
  image: rancher/load-balancer-service
  links:
  - ImageServer-Rhonda:ImageServer-Rhonda
  - PHPMyAdmin:PHPMyAdmin
  stdin_open: true
ImageServer-Rhonda:
  restart: always
  tty: true
  image: 192.168.201.110:5000/wrl/nginx-static:latest
  volumes:
  - /sites/prod/imageserver:/var/www/app
  stdin_open: true
PHPMyAdmin:
  ports:
  - 80/tcp
  restart: always
  tty: true
  image: nazarpc/phpmyadmin
  links:
  - MariaDB-Master:mysql
  stdin_open: true
MariaDB-Master:
  ports:
  - 3306/tcp
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: [redacted]
  tty: true
  image: 192.168.201.110:5000/wrl/mariadb:latest
  volumes:
  - /data/db/mariadb-master:/var/lib/mysql:rw
  - /backup/db/mariadb-master:/data/backup/db:rw
  stdin_open: true

And the rancher-compose file:

MainLB-SSL:
  load_balancer_config:
    lb_cookie_stickiness_policy:
      cookie: haproxy_sticky
      domain: ''
    description: Main load balancer
    name: MainLB-SSL config
  default_cert: wrlweb.com
ImageServer-Rhonda:
  scale: 1
PHPMyAdmin:
  scale: 1
MariaDB-Master:
  scale: 1

What version of Rancher-compose are you using? Can you do a rancher-compose -v? Also, what version of Rancher are you running?

One thing that’s weird is that in your original post you are linking to Main/MariaDB:mysql, but in your docker-compose.yml of your Main stack, it’s called MariaDB-Master.

Also, you might find this issue on Expose relevant. Basically, rancher-compose ignores “Expose”. There was an issue with expose in previous rancher-compose release. The latest version (v0.4.1) has a fix.

Yeah, I copied the wrong YAML file. I actually referenced MariaDB-Master in the YAML file Ive been trying to use. I had thought before that the dashes were messing it up so I copied MariaDB-Master into another container called MariaDB and tried using that to no avail.

When I originally posted this thread I was using rancher-compose 0.4.0 but I upgraded the other day to 0.4.1 and it still gives the marshaling error.

This issue should be fixed in the next release of Rancher-compose, which should come out this week.