Bug 1221836 - nodejs control script should wait for http to be available
Summary: nodejs control script should wait for http to be available
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Michal Fojtik
QA Contact: Wenjing Zheng
URL:
Whiteboard:
Depends On:
Blocks: 1264210
TreeView+ depends on / blocked
 
Reported: 2015-05-15 00:51 UTC by Andy Grimm
Modified: 2019-07-11 09:10 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1264210 (view as bug list)
Environment:
Last Closed: 2015-07-07 23:49:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Andy Grimm 2015-05-15 00:51:29 UTC
Description of problem:

Currently, we generally recommend that people use "hot_deploy" with nodejs.  In some cases, a nodejs application with thousands of files in its modules directory can take several seconds (even 20 or 30 seconds) to start.  When a new version of a scaled app is deployed, what we should be able to do is rotate through all of the app's nodejs gears and deploy / restart them in sequence.  hot_deploy does not do this because it assumes a restart is unnecessary.  If use_npm is enabled and hot_deploy is disabled, then we should have logic similar to the jboss cartridges' "ishttpup" to block until the app is ready, so that gear rotation can work.

Ideally we would have some way to wait for apps to reload in hot_deploy mode as well, but this seems like it would be a complete rearchitecting of the scaled app code (and how would you know when the reload actually started, since it's dependent on supervisor's poll interval?)  So this suggestion of disabling hot_deploy and using npm is the best I could come up with.  Other solutions would also be welcome.

Comment 1 Michal Fojtik 2015-05-18 09:43:02 UTC
Andy, at minimum I can add 'ishttpup' check into the 'start' operation of the nodejs cartride that waits (60 seconds?) till the HTTP port is available. As you said, for hot_deploy that check will be noop as the supervisor process will keep serving the port 8080 all the time.

To verify that the application was deployed (and all code changes are now loaded), you will have to have some 'health-check' mechanism that will tell you current GIT ref. However, I can't think of a simple way how to hijack this into the user application...

Comment 2 Michal Fojtik 2015-05-18 11:10:05 UTC
https://github.com/openshift/origin-server/pull/6143

Comment 3 openshift-github-bot 2015-06-09 18:31:29 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/9f59ea95fc34af03c3aa990d726a9569353fd51f
Bug 1221836 - Add check if the HTTP port is open for nodejs cartridge

Comment 4 wewang 2015-06-12 08:11:55 UTC
Version: devenv_5545
 Steps to Reproduce:
 1. Login and create app
    rhc app-create -a nodejs nodejs-0.10 -s
 2. Check markers directory
    cd .openshift/markers, thers is no use_npm, no hot_deploy included
 3. Visit app's url
 4. Touch the file use_npm
    touch use_npm
 5. Modify index.html 
    vi index.html
 6. Push the change
    git add .;git commit -amp;git push
 7. Visit app's url
 8. Touch hot_deploy and remove use_npm
    touch hot_deploy && rm -rf use_npm
 10. Modify index.html
 11. Push the change
     git add .;git commit -amp;git push
 12. Visit app's url

Actual results:
http appears to work quickly ,it's about 20s.
     
Expected results:
it should wait for http to be available.

Comment 7 Wenjing Zheng 2015-06-12 08:45:07 UTC
QE cannot reproduce this bug on devenv_5545 with steps in comment #4(please ignore the Expected result part)

Comment 8 Jakub Hadvig 2015-06-26 09:34:49 UTC
Can't reproduce this issue. Putting ON_QA

Comment 9 wewang 2015-06-29 05:45:49 UTC
Verified on devenv-5563

app's url is available in less than 10s


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