Search This Blog

Thursday, March 7, 2019

cloud foundry resource exhaustion event

If you are trying to push a simple java app using java build pack which uses openjdk 8
and you are facing an issue of resource exhaustion it could be because of bad memory
paramters. try increasing the XX:MaxMetaspaceSize if your Jar is big in size.

for e.g your Jar is 90 mb it should be atleast 200 mb, i wasted lot of time on this.
This parameter you can set in app setttings on pcf , under user environment variables.
restage and it should not give you resource exhausted warnings...

symtom logs

//////////////

 Internal Error (javaCalls.cpp:53), pid=xx, tid=xxxxxxxxxxxxxxxxxxxxx
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # JRE version: OpenJDK Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # Java VM: OpenJDK 64-Bit Server VM (25.144-b01 mixed mode linux-amd64 compressed oops)
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
2017-10-11T17:05:31.80+0200 [APP/PROC/WEB/3]OUT #

pcf tcp routing ... will make you cry..

tcp routing in pcf can be a pain in the A*** believe me..
here is what you can do .. if you app spring or whatever is listening on a port like 8080 
exposed from SERVER_PORT=$PORT via buildpack .. which can also be configured in application.properties 
of boot like server.port = 9080 or whatever.

Point is , if http app then pcf will directly route traffic via route to your app on 80/443 else you will have to create
tcp domain and route and a router group , can use default tcp router group and get the traffic on non tcp port.

also you can see if you can run your non http app on 443 if thats possible.
if you are bound to use some other port, you gotta configure all th is.

you can ssh in the cf app using cf ssh app name and do a netstat -an and ps-ef to see which 
port your app is listening to also you directly run java via the /app/.java_buildpack/.././java -cp and your main file name 
if you have a normal java app and you are listening to a port inside your code..

i tried to curl from outside container  to a spring hello world and it will let me curl the https endpoint even 
though the boot was running on 8008 on container.. and when i was trying to run a java jar listening on 9877 
it will let me curl the end point https one but it will give 502 bad gateway.. i guess because the endpoint is expecting 
non http traffic ,, i mean tcp traffic .. and cf router gives bad gateway error..

point is... get the admin rights and configure tcp routing.. or find if your app can run on 443/80 even if tcp traffic.. try it.. 



Tuesday, March 5, 2019

How to configure pivotal cloud foundry onperm/laptop

If you have trial limitation with pcf trial account and you are not able to host anything due to resource constraints
you can configure the pivotal onperm single node virtual machine using the pcfdev.

Prerequisites 
Windows laptop 8 Gb ram and Virtual box 5.2 and  pcfdev plugin download from pivotal
make sure you get 30 version , lot of bugs are fixed in it. also cf cli is required

Now go to folder where pcfdev downloaded extracted // do not run pcfdev on a VM else it wont work
and run the powershell in admin mode before starting dev 
cf install-plugin cfdev
cf dev start // it will take ages like an hour or so let all services run 
if all is well you should see 58 of 58 services started , hello message else break your head 
cf dev ssh will land you inside the machine , it will provision in VB 
To debug ssh to dev using cf dev ssh -- /var/vcap/monit folder and sudo tail the monit.log 
also you can grep the drain and other libraries in the /var/pcfdev/run.log
check here  /var/vcap/sys/log/syslog_drain_binder/syslog_drain_binder.log
admin/admin is the cred to login to the api end point 
cf login -a  api.local.pcfdev.io  --skip-ssl-validation // user and pass should work .. 
you will be able to see org/quota/space 
cf create-space myspace -o orgname
cf target -s myspace
now push
create a space and push you app by cf push -f manifest.yml 
sample manifest.yml 
applications:  - name: fixserver    memory: 1024M    buildpack: https://github.com/cloudfoundry/java-buildpack.git    path: server.jar    hostname: fixserver    health-check-type: process  
health check type of process will help your app to boot atleast else it will check that port 
and mark your app as failure.

It should push you app to pcf cloud , now you can login to dash of pcf and see the logs 
also from command line 
cf logs fixserver // you can also ssh to app container by cf ssh appname

docker push appname --docker-image url  from hub
cf enable-feature-flag diego_docker    

Heroku clone a running up and update it with cli

Download the heroku cli and change the ssh keys if you have a previous installation of keys from some other account
 $heroku auth:logout
$heroku auth:login 
 Openweb page and authenticate with your creds, it will log you in.

download your code from a running app with 

heroku git:clone -a APP-NAME

Do a  git add .   // if you have changed a file
git commit -m "dfd"
git push heroku master.

You can see your updated app after the push is complete