ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 41 forks source link

Make postinstall.js exit with code 1 on error #145

Closed scagood closed 2 years ago

scagood commented 2 years ago

Please ensure all items are complete before opening.

What

Make postinstall.js exit with code 1 on error, thus preventing a "successful" install.

Why

Occasionally we get "successfully" built docker images that just completely lack the queue client (this seems to happen in batches).

Here are a couple of built images: image You can see that a couple of them are remarkably small compared to the rest.

This would not be an issue if it were not for the fact that said images are connected to a Continuous Deployment pipeline, causing errors like this to occasionally appear in my test environment: image

Testing

$ docker run -it --entrypoint=/bin/bash node:16.16

# From here the entire work flow is in the container

$ npm install --ignore-scripts ibmmq
<snip>

# Make changes in docker image
$ nano node_modules/ibmmq/postinstall.js

# First a clean success
$ (cd node_modules/ibmmq; node postinstall.js)
Downloading IBM MQ Redistributable C Client runtime libraries - version 9.3.0.0
Getting https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.3.0.0-IBM-MQC-Redist-LinuxX64.tar.gz
Unpacking libraries...
Removing 9.3.0.0-IBM-MQC-Redist-LinuxX64.tar.gz

# Check the exit code
$ echo $?
0

# Reset state
$ rm -rf node_modules/ibmmq/redist/
# Break the download
$ echo '127.0.0.1 public.dhe.ibm.com' >> /etc/hosts

# Now a failed download
$ (cd node_modules/ibmmq; node postinstall.js)
Downloading IBM MQ Redistributable C Client runtime libraries - version 9.3.0.0
Getting https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/9.3.0.0-IBM-MQC-Redist-LinuxX64.tar.gz
Error occurred downloading IBM MQ Redistributable C Client: connect ECONNREFUSED 127.0.0.1:443
You will need to manually install it.
Removing 9.3.0.0-IBM-MQC-Redist-LinuxX64.tar.gz

# Check the exit code
$ echo $?
1
ibmmqmet commented 2 years ago

Thanks for that. I was planning on doing something similar anyway, after seeing a few people have issues. Especially after npm install stopped printing progress messages by default.