The Basics
I used the DIY cartridge before and played with it a bit. Next I wanted to create a custom cartridge. As usual for me the first attempt was more about learning about the system than about getting things to work right away. And I must say it was a bit annoying when you start with zero or little knowledge.
A working version is here : https://bitbucket.org/markus_ebenhoeh/openshift-cartridge-spring-boot-jar-runner
Learn from my mistakes:
- make sure that you use the right cartridge version. I followed code that was newer than the version I was running, but even then I mixed old with new conventions. E.g. I used OPENSHIFT_LOG_DIR but that does not exist yet.
-
don’t git push your code, then find the manifest URL and then try to test it. Either use the card reflector (usage) or if you already have an http server running, just serve your code directly I changed the source to a zip on my http server and ran this just before I retried with a new application rm -f cartridge-name.zip; zip -r cartridge-name.zip *; chmod a+rX -R $PWD In the end, I just mounted a shared folder and referred the source URL to that with file:///mnt/public-shared/openshift-cartridge-spring-boot-jar-runner while still hosting the same folder via http for the manifest access
-
to test my cartridge I added a spring-boot application jar with an embedded tomcat. Instead of taking the smallest web-app jar that I could find I took a 29MB jar and added it into the template. This is stupid on many levels, but it also meant that it took long to do the git pull and the start and the transfer.etc having a test app in the template is important for the testing of the cartridge and afterwards for the use of it, but a smaller application is what I am going for next.
Debugging a Failing Cartridge
When my cartridge completely failed I had no output and nothing to go on. I was logged on to my test origin VM but the gear/application folder would simple be deleted at the end. So all my test log output that was supposed to show me were it failed and what the environment looked like would vanish
So while being logged on to the test VM with root I did this dodgy thing:
cd /var/lib/openshift/
# my user/gear/app folder always starts with 5 and I had no other gears set-up
unalias cp
while true; do cp -a 5* tmp/ ; usleep 100000; echo next ;done
once it failed I had more information to go on with. especially the nev folders are useful
Other problems:
- I would like to see a cartridge life-cycle flow. e.g. copy file, call install, call setup etc.
- when are ENV variables available? Can I refer to my own env_xyz.erb variables when defining new ones?
- I still have no idea how the repo
- there has to be a better way to test this then to do an add-app with the updated cartridge.
- I could not find any debug output when my cartridge completely failed
- CDK is not working on Origin bug
OpenShift Cartridge Development Kit
ran this against OpenShift Online since CDK is not working on Origin bug. not sure what the point is, though. I think it is about being able to have a simple way of hosting the cartridge for a certain version
rhc create-app mycart http://cdk-claytondev.rhcloud.com
The cartridge 'http://cdk-claytondev.rhcloud.com' will be downloaded and installed
Application Options
-------------------
Domain: testcdk
Cartridges: http://cdk-claytondev.rhcloud.com
Gear Size: default
Scaling: no
Creating application 'mycart' ... done
The CDK is configured with password XXXXXXXXXXXXXXX for builds (use 'admin' as the user)
Waiting for your DNS name to be available ... done
Cloning into 'mycart'...
The authenticity of host 'mycart-testcdk.rhcloud.com (54.204.113.11)' can't be established.
RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'mycart-testcdk.rhcloud.com,54.204.113.11' (RSA) to the list of known hosts.
X11 forwarding request failed on channel 0
Your application 'mycart' is now available.
URL: http://mycart-testcdk.rhcloud.com/
SSH to: 539@mycart-testcdk.rhcloud.com
Git remote: ssh://539@mycart-testcdk.rhcloud.com/~/git/mycart.git/
Cloned to: /xdata/local/dev/markus/git/cdk/mycart
Run 'rhc show-app mycart' for more details about your app.
Lifeccyle Notes
first installation
20140609_034324 setup called with --version 1.0.2
20140609_034324 install called with --version 1.0.2
20140609_034324 control called with start
20140609_034324 start_app called
20140609_034324 Starting spring-boot-bin-jar-runner cartridge
20140609_034324 start_app: Using jarfile=/var/lib/openshift/539/spring-boot-jar-runner/web-app-jar/simple-executable-jar-web-server-0.0.1.jar
20140609_034324 control : checkSpringBootAppIsRunning still checking
20140609_034325 control start successfully started the application
git push new app code
20140609_034411 control called with stop
20140609_034411 stop_app called
20140609_034411 Stopping spring-boot-bin-jar-runner cartridge
20140609_034411 Sending SIGTERM to java:4556 ...
20140609_034411 control called with pre-repo-archive
20140609_034412 control called with update-configuration
20140609_034412 control called with pre-build
20140609_034412 control called with build
20140609_034412 build called with
20140609_034412 control called with update-configuration
20140609_034412 control called with deploy
20140609_034412 deploy called with
20140609_034412 control called with start
20140609_034412 start_app called
20140609_034412 Starting spring-boot-bin-jar-runner cartridge
20140609_034412 start_app: Using jarfile=/var/lib/openshift/539/spring-boot-jar-runner/web-app-jar/simple-executable-jar-web-server-0.0.1.jar
20140609_034412 control : checkSpringBootAppIsRunning still checking
20140609_034412 control start successfully started the application
20140609_034432 control called with post-deploy
There is considerable time spent between “start” and “post-deploy” not sure what’s happening there.