api_z1 failing during deployment

Johannes Hiemer
5. August 2015
Reading time: 2 min

When deploying Cloud Foundry sometimes the deployment of api_z1 is failing. This may have various reasons. One of them I will describe here. The first step is to get into the machine via bosh ssh api_z1 0 and start tailing the logs with:

cd /var/vcap/sys/log
tail -f */*.log

Then you should see the errors. One of them may this one:

root@e286ee14-ec02-4a1b-8d23-af183e1e79ea:/var/vcap/sys/log# tail nginx_ctl.err.log
[2015-07-24 04:54:18+0000] ------------ STARTING nginx_ctl at Fri Jul 24 04:54:18 UTC 2015 --------------
[2015-07-24 04:54:18+0000] nginx: [emerg] duplicate location /Vwg7pCRaWuiAeq7bsk74/ in /var/vcap/jobs/cloud_controller_ng/config/nginx.conf:88
[2015-07-24 04:55:09+0000] ------------ STARTING nginx_ctl at Fri Jul 24 04:55:09 UTC 2015 --------------
[2015-07-24 04:55:09+0000] nginx: [emerg] duplicate location /Vwg7pCRaWuiAeq7bsk74/ in /var/vcap/jobs/cloud_controller_ng/config/nginx.conf:88
[2015-07-24 04:55:49+0000] ------------ STARTING nginx_ctl at Fri Jul 24 04:55:49 UTC 2015 --------------
[2015-07-24 04:55:49+0000] nginx: [emerg] duplicate location /Vwg7pCRaWuiAeq7bsk74/ in /var/vcap/jobs/cloud_controller_ng/config/nginx.conf:88
[2015-07-24 04:56:29+0000] ------------ STARTING nginx_ctl at Fri Jul 24 04:56:29 UTC 2015 --------------
[2015-07-24 04:56:29+0000] nginx: [emerg] duplicate location /Vwg7pCRaWuiAeq7bsk74/ in /var/vcap/jobs/cloud_controller_ng/config/nginx.conf:88
root@e286ee14-ec02-4a1b-8d23-af183e1e79ea:/var/vcap/sys/log# vi /var/vcap/jobs/cloud_controller_ng/config/nginx.conf

When you look into the file then you should see this block to times:

# used for x-accel-redirect uri://location/foo.txt
# nginx will serve the file root || location || foo.txt
location /Vwg7pCRaWuiAeq7bsk74/ {
internal;
root /var/vcap/nfs/shared;
}

The reason is that you may have misconfigured the secrets for cc:.

cc:
droplets:
droplet_directory_key: (( properties.def_key "-dp" ))
buildpacks:
buildpack_directory_key: (( properties.def_key "-bp" ))
staging_upload_user: (( properties.def_user ))

If droplet_directory_key and buildpack_directory_key are the same, the deployment of api_z1 0 will always fail. So be aware to use different keys here!