Bug 984991

Summary: ruby 1.9 cartridge defaults to "'bundle exec rake assets:precompile'"
Product: OpenShift Container Platform Reporter: Brenton Leanhardt <bleanhar>
Component: ContainersAssignee: Brenton Leanhardt <bleanhar>
Status: CLOSED ERRATA QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.2.0CC: adellape, bmeng, ejacobs, gpei, libra-onpremise-devel, xtian, yanpzhan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openshift-origin-cartridge-ruby-0.4.10.1-1 Doc Type: Bug Fix
Doc Text:
Due to logic in the Ruby cartridge expecting a Rails application layout, users of Sinatra and other popular Ruby web frameworks experienced confusing error messages about asset precompilation. With this fix, precompilation is only attempted if the Ruby application Rakefile supports it and the error messages no longer occur.
Story Points: ---
Clone Of: 970658 Environment:
Last Closed: 2013-08-05 17:19:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 970658    
Bug Blocks:    

Description Brenton Leanhardt 2013-07-16 14:13:51 UTC
+++ This bug was initially created as a clone of Bug #970658 +++

Description of problem:
It appears that the ruby 1.9 cartridge has a "bundle exec rake assets:precompile" in it by default somewhere.

Unfortunately, not all ruby/rack applications are rails, and, therefore, there may not be any default rake actions, let alone "assets:precompile".

Steps to Reproduce:
1. Create a ruby 1.9 application
2. Push code into it that has no rails/rake

Actual results:
remote: Precompiling with 'bundle exec rake assets:precompile'
remote: rake aborted!
remote: Don't know how to build task 'assets:precompile'
remote: 
remote: (See full trace by running task with --trace)

Expected results:
Should somehow figure out if we are using Rails or not and not try to do the precompile if the rake action doesn't exist.

--- Additional comment from Jhon Honce on 2013-06-04 11:43:33 EDT ---

Please verify this is not an issue with the V2 cartridges.

--- Additional comment from Hiro Asari on 2013-06-04 14:29:58 EDT ---

At the moment, on v2, 'set +e' and 'set -e' wrap the call to 'rake assets:precompile', so that the failure from this rake task is not fatal. The error message is annoying, but it should not stop the deployment.

--- Additional comment from Hiro Asari on 2013-06-05 15:18:07 EDT ---

As for v1, STDERR is swallowed at the moment, so the user should not see this error message. (See https://bugzilla.redhat.com/show_bug.cgi?id=862919, which was fixed many months ago by https://github.com/openshift/origin-server/commit/e7dba7f.) I am not sure how the error message is showing up now.

Eric, can you check how recent your origin server is?

--- Additional comment from Hiro Asari on 2013-06-05 15:34:36 EDT ---

Test case (ensure the server is using v1 cartridges):

rhc app create rack ruby-1.9 -l $RHC_USERNAME --server $RHC_SERVER
cd rack
touch Rakefile
curl -O https://gist.github.com/BanzaiMan/71d71d884937848d3184/raw/4824c4815eb785de278e356b9b8a22a347520a2f/Gemfile
bundle install
git add Rakefile Gemfile*
git commit -m 'empty Rakefile and Gemfile with "rake"'
git push

--- Additional comment from Hiro Asari on 2013-06-05 15:36:16 EDT ---

https://github.com/openshift/origin-server/pull/2763

--- Additional comment from Hiro Asari on 2013-06-05 15:37:36 EDT ---

Eric,

I confirmed the error message bubbling up to the git output in the latest server, so you don't have to do anything further. I apologize for the confusion.

--- Additional comment from openshift-github-bot on 2013-06-05 18:35:14 EDT ---

Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/2741c4b8020fb575199a275ed9581a7912a912d0
Bug 970658

Run 'rake assets:precompile' only if that Rake task is available.

--- Additional comment from Hiro Asari on 2013-06-06 09:15:03 EDT ---

It should be tested on v1 (1.8 and 1.9) and v2 cartridges.

--- Additional comment from Meng Bo on 2013-06-08 04:02:36 EDT ---

Tested on devenv_3336,

For both ruby1.9 and ruby1.8

With steps in comment#4, issue fixed.

Total 4 (delta 0), reused 0 (delta 0)
remote: Stopping Ruby cart
remote: Waiting for stop to finish
remote: Running build on Ruby cart
remote: Bundling RubyGems based on Gemfile/Gemfile.lock to repo/vendor/bundle with 'bundle install --deployment'
remote: Fetching source index for https://rubygems.org/
remote: which: no sudo in (/bin:/usr/bin:/usr/sbin)
remote: Installing rake (10.0.4) 
remote: Using bundler (1.0.21) 
remote: Your bundle is complete! It was installed into ./vendor/bundle
remote: Starting Ruby cart
To ssh://4faf90e4d00e11e287d822000a988362.rhcloud.com/~/git/rack18.git/
   f23e4a1..dd9afb1  master -> master

--- Additional comment from Meng Bo on 2013-06-08 04:21:06 EDT ---

For v1:

Total 4 (delta 1), reused 0 (delta 0)
remote: restart_on_add=false
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Waiting for stop to finish
remote: Done
remote: restart_on_add=false
remote: Running .openshift/action_hooks/pre_build
remote: Bundling RubyGems based on Gemfile/Gemfile.lock to repo/vendor/bundle with 'bundle install --deployment'
remote: Fetching gem metadata from https://rubygems.org/..
remote: Installing rake (10.0.4) 
remote: Using bundler (1.1.4) 
remote: Your bundle is complete! It was installed into ./vendor/bundle
remote: Running .openshift/action_hooks/build
remote: Running .openshift/action_hooks/deploy
remote: hot_deploy_added=false
remote: Done
remote: Running .openshift/action_hooks/post_deploy
To ssh://d573874ad0c611e2970622000a9aa12e.rhcloud.com/~/git/rack19.git/
   d15f4ed..3d3449c  master -> master

Comment 4 Gaoyun Pei 2013-07-19 05:37:32 UTC
Verify this bug on puddle 1.2/2013-07-18.4

Steps:
1. Create ruby-1.8 and ruby-1.9 app
2. cd app2
   touch Rakefile
   curl -O https://gist.github.com/BanzaiMan/71d71d884937848d3184/raw/4824c4815eb785de278e356b9b8a22a347520a2f/Gemfile
   bundle install
3.  git add Rakefile Gemfile* && git commit -m 'empty Rakefile and Gemfile with "rake"' && git push
[root@dhcp-8-133 app2]# git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 490 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Stopping Ruby cart
remote: httpd: Could not reliably determine the server's fully qualified domain name, using node1.osetestv2auto.com for ServerName
remote: Waiting for stop to finish
remote: Running build on Ruby cart
remote: Bundling RubyGems based on Gemfile/Gemfile.lock to repo/vendor/bundle with 'bundle install --deployment'
remote: Fetching gem metadata from https://rubygems.org/..
remote: Installing rake (10.1.0) 
remote: Using bundler (1.1.4) 
remote: Your bundle is complete! It was installed into ./vendor/bundle
remote: Starting Ruby cart
remote: httpd: Could not reliably determine the server's fully qualified domain name, using node1.osetestv2auto.com for ServerName
To ssh://51e8aca66088674521000018.com/~/git/app2.git/
   0c01c80..78713be  master -> master

Comment 7 errata-xmlrpc 2013-08-05 17:19:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1138.html