Bug 1013064 - Pushing the first commit to an empty git repo (created using --from-code=empty) results in Git fatal error
Summary: Pushing the first commit to an empty git repo (created using --from-code=empt...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Containers
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Jakub Hadvig
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-27 18:27 UTC by Clayton Coleman
Modified: 2015-05-14 23:12 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-17 13:26:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Clayton Coleman 2013-09-27 18:27:15 UTC
Scenario:
1) Create a new application using rhc create-app foo php-5 --from-code=empty
2) Add a git remote for that app to an existing repo
2) In an existing repo, do 'git push <remote> master'

The prereceive is assuming that the repo has at least 1 commit - when --from-code=empty that is not the case.  So a fatal error (which doesn't actually prevent) execution is displayed to the user:

Counting objects: 55, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (41/41), done.
Writing objects: 100% (55/55), 15.60 KiB, done.
Total 55 (delta 16), reused 41 (delta 9)
remote: fatal: Not a valid object name master
remote: fatal: Invalid revision range 0000000000000000000000000000000000000000..888ba90a3aec6cd55f9b6e200275becce4376baa
remote: Stopping Ruby cartridge
remote: Syntax error on line 10 of /var/lib/openshift/5245cc609f79cf2b93000716/ruby/etc/conf.d/openshift.conf:
remote: DocumentRoot must be a directory
remote: httpd (no pid file) not running

We should guard against that case in prereceive - if the repo is init'd but has no commits we shouldn't be checking the commit values.

Not super high priority, but RHC is gearing up to start using =empty more aggressively and I want to stomp this.  Was a consequence of the change I made to support "empty" earlier on - we didn't catch it during test.  Can be deferred, but valuable to fix.

Comment 1 Jakub Hadvig 2013-10-11 11:41:07 UTC
Based on reported bug report i've updated the check for the branch in the openshift app repo. If the return value of the git ls-tree... is unsuccessful and returns value > 0 ( no branch is present ), the output is redirected to 2/dev/null, and no hot deploy is needed.

Also when the app is created with empty repo and no initial (or other commits) are present, no hot deploy is needed.

Pull Req.: https://github.com/openshift/origin-server/pull/3837

Comment 2 Andy Goldstein 2013-10-11 19:24:51 UTC
Hi Jakub,

There were a few issues with the gear script relating to git pre/postreceive and marker files. The following PR incorporates fixes for this BZ as well as other items.

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

Comment 3 Meng Bo 2013-10-12 08:25:33 UTC
Checked on devenv_3891, issue has been fixed.


$ git push origin master
Counting objects: 3710, done.
Compressing objects: 100% (3291/3291), done.
Writing objects: 100% (3710/3710), 3.35 MiB | 891 KiB/s, done.
Total 3710 (delta 63), reused 3710 (delta 63)
remote: Stopping PHP cartridge
remote: Syntax error on line 2 of /var/lib/openshift/5259037548d5f94ce3000179/php/configuration/etc/conf.d/openshift.conf:
remote: DocumentRoot must be a directory
remote: httpd (no pid file) not running
remote: Building git ref 'master', commit d710f99
remote: Building PHP cartridge
remote: Preparing build for deployment
remote: Prepared deployment artifacts in /var/lib/openshift/5259037548d5f94ce3000179/app-deployments/2013-10-12_04-12-05.385
remote: Deployment id is 7530b76b
remote: Activating deployment
remote: 
remote: done.
remote: ==================================================
remote:   Wiki-Admin login: admin
remote:   Wiki-Admin password: OpenShiftAdmin
remote:   Don't forget to change your wiki admin password!
remote: ==================================================
remote: Starting PHP cartridge
remote: Result: success
remote: Activation status: success
remote: Deployment completed
To ssh://5259037548d5f94ce3000179.rhcloud.com/~/git/php1.git/
 * [new branch]      master -> master

After git push, the code added to the app, and app works well.


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