Bug 970150 - Ruby asset compilation fails if the app name starts with a numeral
Ruby asset compilation fails if the app name starts with a numeral
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
2.x
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Hiro Asari
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-03 10:37 EDT by Fotios Lindiakos
Modified: 2015-05-14 19:20 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-08-29 08:47:35 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Fotios Lindiakos 2013-06-03 10:37:42 EDT
Description of problem:
When creating an application with a name of all numbers, asset compilation fails. This is only hit after embedding the Rails quickstart, which requires asset compilation. But since this code is in the Ruby cartridge, the fix will need to be there.

Version-Release number of selected component (if applicable):


How reproducible:
Always


Steps to Reproduce:
1. rhc app create 12345 ruby-1.9 mysql-5.1 --from-code https://github.com/openshift/rails-example --debug

Actual results:
Precompiling with 'bundle exec rake assets:precompile'
/opt/rh/ruby193/root/usr/bin/ruby /var/lib/openshift/.../rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
can't convert Fixnum into String


Expected results:
It should succeed


Additional info:
Full stack trace here: http://pastebin-fotios.rhcloud.com/1024/
This may actually be a bug in Rails, but we may be able to get around it by properly quoting the app name
Comment 1 Fotios Lindiakos 2013-06-03 10:56:26 EDT
So this may not be a "bug" in Rails. Rails does not allow app names of all numbers:
rails new 12345
Invalid application name 12345. Please give a name which does not start with numbers.

Not sure how this should be handled, will bring it up with the runtime team.
Comment 2 Dan Mace 2013-06-03 12:01:47 EDT
Marking as future feature.
Comment 3 Dan McPherson 2013-08-08 14:14:35 EDT
Note: We are only looking for a better error message for the fix.
Comment 4 openshift-github-bot 2013-08-12 15:29:49 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/6400c02c79d3a7dfd7f5d7884bbcb72d8fcd1dc1
Bug 970150

Fail early during the build cycle if a Rails app name starts with a
numeral.

We should fail before we run `bundle install`, since it is completely
unnecessary if Rails can't run.

If the application is created with `--from-code`, the initial build will
fail, with error message like this:

```
Creating application '12345' ...
The initial build for the application failed: Shell command
'/sbin/runuser -s /bin/sh 80e4c0ea037a11e3962922000ab2046b -c "exec
/usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c0,c502' /bin/sh
-c \"gear
postreceive >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255

.Last 10 kB of build output:
Stopping Ruby cart
httpd (no pid file) not running
Invalid Rails application name. Please delete this applicatin and
re-create it with a name which does not start with numbers
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: Failed to execute: 'control pre-build' for
/var/lib/openshift/80e4c0ea037a11e3962922000ab2046b/ruby

For more details about the problem, try running the command again with
the '--trace' option.
```

If the application is created from a template Rack app, and updated via
`git pull -s recursive -X theirs`, the build will fail on the first
push:

```
remote: Stopping Ruby cart
remote: Waiting for stop to finish
remote: CLIENT_ERROR: Invalid Rails application name. Please delete this applicatin and re-create it with a name which does not start with
numbers
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: Failed to execute: 'control pre-build' for /var/lib/openshift/520924b77b2a19115a000001/ruby
remote:
remote: For more details about the problem, try running the command again with the '--trace' option.
To ssh://520924b77b2a19115a000001@12345-fooooooooooo.dev.rhcloud.com/~/git/12345.git/
   9b5a31d..398f08a  master -> master
```
Comment 6 Meng Bo 2013-08-13 05:42:41 EDT
Tested on devenv_3641, with 2 methods, both of them can show the useful information about the invalid app name.



The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 1747d54603fc11e3aa2722000a904a26 -c "exec /usr/bin/runcon
'unconfined_u:system_r:openshift_t:s0:c0,c549' /bin/sh -c \"gear postreceive >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255

.Last 10 kB of build output:
Stopping Ruby cart
httpd (no pid file) not running
Invalid Rails application name. Please delete this applicatin and re-create it with a name which does not start with numbers
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: Failed to execute: 'control pre-build' for /var/lib/openshift/1747d54603fc11e3aa2722000a904a26/ruby

For more details about the problem, try running the command again with the '--trace' option.



remote: CLIENT_ERROR: Invalid Rails application name. Please delete this applicatin and re-create it with a name which does not start with numbers
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: Failed to execute: 'control pre-build' for /var/lib/openshift/5209ef11af319a22f5000004/ruby
remote: 
remote: For more details about the problem, try running the command again with the '--trace' option.
To ssh://5209ef11af319a22f5000004@191919-bmengdev.dev.rhcloud.com/~/git/191919.git/
   55b1fbd..c4b5a93  master -> master


But there is a typo in the error message, the 2nd 'applicatin' should be 'application'.

I assign this bug back to fix the text issue.
Comment 7 Meng Bo 2013-08-13 05:52:52 EDT
The 2 methods in the last comment are:

1. Create rails app with --from-code
rhc app create 12345 ruby-1.9 mysql-5.1 --from-code https://github.com/openshift/rails-example --debug

2. Add the code to an existing app with following the steps in
https://github.com/openshift/rails-example
Comment 8 Hiro Asari 2013-08-13 10:11:31 EDT
It turns out that the previous commit broke every Rails app ("foo", say). The fix should be landing soon.
Comment 9 openshift-github-bot 2013-08-13 10:24:45 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/b46b39cd9d0894b38b5507cc1572c08d7e9dfe33
Follow up fix for Bug 970150

It turns out that 6400c02 wasn't really working.
The inner `if` clause, `$?` is `0` no matter what the result from
the app name check, so that any app name would fail for Rails.

This fixes that.
Comment 10 Hiro Asari 2013-08-13 10:28:58 EDT
The above analysis regarding $? may not be correct, but the symptom is accurately described (that all Rails apps failed), and the fix works.

https://github.com/BanzaiMan/origin-server/commit/b46b39cd9d0894b38b5507cc1572c08d7e9dfe33#commitcomment-3849430
Comment 11 Meng Bo 2013-08-13 23:31:01 EDT
Checked on devenv_3646, issue has been fixed.

For app with numeric name, it will return correct error message.
And for normal app, rails app can be created successfully.

1.
.Last 10 kB of build output:
Stopping Ruby cart
httpd (no pid file) not running
Invalid Rails application name. Please delete this application and re-create it with a name which does not start with numbers
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: Failed to execute: 'control pre-build' for /var/lib/openshift/799f01ee049011e38d5912313d04e829/ruby

For more details about the problem, try running the command again with the '--trace' option.


2.
rhc app create rails ruby-1.9 mysql-5.1 --from-code https://github.com/openshift/rails-example
Application Options
-------------------
  Namespace:   bmengdev
  Cartridges:  ruby-1.9, mysql-5.1
  Source Code: https://github.com/openshift/rails-example
  Gear Size:   default
  Scaling:     no

Creating application 'rails' ... done

  MySQL 5.1 database added.  Please make note of these credentials:
       Root User: adminzKjlLUg
   Root Password: YIcGfg5xbhDq
   Database Name: rails
Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
You can manage your new MySQL database by also embedding phpmyadmin-3.4.
The phpmyadmin username and password will be the same as the MySQL credentials above.

Waiting for your DNS name to be available ... done

Cloning into 'rails'...
Warning: Permanently added 'rails-bmengdev.dev.rhcloud.com,184.73.5.34' (RSA) to the list of known hosts.

Your application 'rails' is now available.

  URL:        http://rails-bmengdev.dev.rhcloud.com/
  SSH to:     842397002501180239118336@rails-bmengdev.dev.rhcloud.com
  Git remote: ssh://842397002501180239118336@rails-bmengdev.dev.rhcloud.com/~/git/rails.git/
  Cloned to:  /root/openshiftest/rails

Run 'rhc show-app rails' for more details about your app.
Comment 12 openshift-github-bot 2013-10-03 11:06:57 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/a9045a821710bd90217504d060d6b5827e8f330a
Allow numeric-only Rails app names

In Bug 970150, we introduced the check to enforce an arbitrary
restriction that the Rails application names cannot start with a
numeral.

While it is true that `rails new` fails if the application name starts
with a numeral, this restriction should not prevent OpenShift from
hosting such an application.

Our quickstart now has a workaround:
https://github.com/openshift/rails-example/pull/29

The issue should be addressed in `mysql2` gem as well.
Comment 13 Hiro Asari 2013-10-04 08:50:55 EDT
For reference: https://bugzilla.redhat.com/show_bug.cgi?id=1014317

Note You need to log in before you can comment on or make changes to this bug.