Description of problem: The cron cartridge does not implement any type of locking. Therefore, if a job for frequency X is already running and it's time to start another job, the second job will be started. The solution is to implement locking for each frequency, and skip runs where the lock cannot be obtained. Version-Release number of selected component (if applicable): 2.0.20 How reproducible: Always Steps to Reproduce: 1. Create an application and embed the cron cartridge. 2. Create a minutely job that runs for 2 minutes and marks its end in a log file in the application's dir (sample code below). Actual results: End of job should be marked in log file. Expected results: End of job is not marked in log file; subsequent runs overwrite log file. Additional info:
Test job code (designed to work with a ruby app): ========== #!/bin/bash date >> $OPENSHIFT_RUBY_LOG_DIR/test.log sleep 120 echo 'test job complete!' >> $OPENSHIFT_RUBY_LOG_DIR/test.log ========== This should go in the app's .openshift/cron/minutely and have the executable bit set.
I've introduced locking that will result in a skipped run for any frequency if a job for that frequency is already running. A skipped run will result in a message like so in /var/log/messages: :SKIPPED: minutely cron run for openshift user '53e8fde8be0742d1bb42cad10da24345'
Fix is present in devenv AMI 2556.
Verified on devenv_2558 Steps: 1. Create one app and embed cron cartridge 2. Create a minutely job that runs for 2 minutes and marks its end in a log file in the application's dir (sample code below). #!/bin/bash date >> $OPENSHIFT_PHP_LOG_DIR/test.log sleep 120 echo 'test job complete!' >> $OPENSHIFT_PHP_LOG_DIR/test.log 3. Git push Check locking is enabled for cron cartridge On app's gear: [php1-2558t.dev.rhcloud.com logs]\> tailf test.log Wed Dec 5 21:39:03 EST 2012 test job complete! On instance, a skipped run is logged Dec 5 21:43:02 ip-10-151-4-201 root[31265]: user-cron-jobs Wed Dec 5 21:43:02 EST 2012: :START: minutely cron run for openshift user 'ef037b3bb9494ffca77423bfdae2fc84' Dec 5 21:43:02 ip-10-151-4-201 root[31275]: user-cron-jobs Wed Dec 5 21:43:02 EST 2012: :SKIPPED: minutely cron run for openshift user 'ef037b3bb9494ffca77423bfdae2fc84'