Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Node applications go into Crashloop #317

Open
ralanlittle opened this issue Apr 3, 2020 · 1 comment
Open

Node applications go into Crashloop #317

ralanlittle opened this issue Apr 3, 2020 · 1 comment

Comments

@ralanlittle
Copy link

Describe the bug
Creating a template application with no changes to the source goes in to a crash loop backoff.

To Reproduce
Steps to reproduce the behavior:

  1. configure appsody with the 0.7.0 stack hub.
  2. Appsody init for node's
  3. establish a web hook for the build and deploy pipeline for the stack
  4. store the project in git, the project builds and deploys and produces the following message in the logs

nodejs-simple@0.1.0 start /project/user-app
node app.js

Hello from Node.js 12!

┌───────────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /opt/app-root/src/.config │
└───────────────────────────────────────────────────────────────┘

As it goes in the crash loop
,

Expected behavior
A clear and concise description of what you expected to happen.

The application to run without the loop

Actual behaviour
What is the actual behaviour.

crashloop

Environment Details (please complete the following information):
fyre, OCP 4.3.0, Kabanero 0.7.0, nodejs stack 0,3,3.

If applicable please specify:

  • CLI version:
  • Collection you are using:

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

The following zip file contains app, build log, and runtime log.
NodeProblem.zip

@sam-github
Copy link

As it goes in the crash loop: there is no evidence of this in the logs. The app runs sucessfully, see NodeProblem/Output from running sample/sample5-5bc758fb8-6qjp8-app.log:

                                                                                 
> nodejs-simple@0.1.0 start /project/user-app                                    
> node app.js                                                                    
                                                                                 
Hello from Node.js 12!                                                           
                                                                                 
┌───────────────────────────────────────────────────────────────┐                
│                    npm update check failed                    │                
│              Try running with sudo or get access              │                
│             to the local update config store via              │                
│ sudo chown -R $USER:$(id -gn $USER) /opt/app-root/src/.config │                
└───────────────────────────────────────────────────────────────┘ 

That's success, it did exactly what the stack template is coded to do: https://github.com/kabanero-io/collections/blob/master/incubator/nodejs/templates/simple/app.js, log a friendly greeting, and exit.

Where are you seeing a crash loop? I read all your logs, and see no loop.

The message is understandably disconcerting, and it appears that whoever forked the kabanero stacks from appsody is using (perhaps inadvertently?) a mixture of RedHat and appsody conventions on where the app src is.

I did an appsody run on your sample from the zip file, docker execed in, and see this:

bash-4.4$ env | egrep 'APPSODY_RUN_ON|/opt/app-root'
HOME=/opt/app-root/src
APPSODY_RUN_ON_CHANGE=npm start --node-options --require=appmetrics-dash/attach
APP_ROOT=/opt/app-root
PATH=/opt/app-root/src/node_modules/.bin/:/opt/app-root/src/.npm-global/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NPM_CONFIG_PREFIX=/opt/app-root/src/.npm-global
bash-4.4$ cd /project/user-app/
bash-4.4$ cat app.js 
console.log("Hello from Node.js 12!")bash-4.4$ npm start

> nodejs-simple@0.1.0 start /project/user-app
> node app.js

Hello from Node.js 12!

┌───────────────────────────────────────────────────────────────┐
│                    npm update check failed                    │
│              Try running with sudo or get access              │
│             to the local update config store via              │
│ sudo chown -R $USER:$(id -gn $USER) /opt/app-root/src/.config │
└───────────────────────────────────────────────────────────────┘
bash-4.4$ ls -l
total 24
-rw-r--r-- 1    1000 1000   10 Apr  3 19:26 README.md
-rw-rw-r-- 1    1000 1000 3473 Mar 23 20:08 app-deploy.yaml
-rw-r--r-- 1    1000 1000   37 Mar 23 20:02 app.js
drwxr-xr-x 2 default root 4096 Mar 10 21:47 node_modules
-rw-r--r-- 1    1000 1000   76 Mar 23 20:02 package-lock.json
-rw-r--r-- 1    1000 1000  358 Mar 23 20:02 package.json
-rw-r--r-- 1    1000 1000    0 Mar 23 20:03 resourceRegistry.log
bash-4.4$ ls -l /opt/  
total 8
drwxrwxr-x 1 default root 4096 Jan 30 08:17 app-root
bash-4.4$ ls -l /opt/app-root/
total 12
drwxrwxr-x 1 default root 4096 Jan 30 08:17 etc
drwxrwxr-x 1 default root 4096 Mar 10 21:47 src
bash-4.4$ ls -l /opt/app-root/src/
total 84
drwxr-xr-x 1 root    root  4096 Mar 10 21:47 node_modules
-rw-r--r-- 1 default root 81852 Mar 10 21:47 package-lock.json
bash-4.4$ ls -ld /opt/app-root/src/
drwxrwxr-x 1 default root 4096 Mar 10 21:47 /opt/app-root/src/
bash-4.4$ cd /opt/app-root/src; npm ls --depth=0                                                              
/opt/app-root/src                                                                                                                                                                              
`-- npm@6.14.2 

A couple things to note:
The app ran OK.

npm is trying to create /opt/app-root/src/.config, but lacks perms.

NPM_CONFIG_PREFIX is set to /opt/app-root/src, perhaps because HOME is set to /opt/app-root/src in the base images (not the collections), or perhaps because of #306?

I'm not an expert on RH images, but I think its expected that the app be installed in $HOME, and that would be /opt/app-root/src for UBI/node, might want to consider doing that. Also, updating npm, as #306 does, probably makes the stack uncertifiable by RedHat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants