2
0

More than 3 years have passed since last update.

Cloud Foundryのデプロイで急にNode.jsが動かなくなった件

Posted at

いつも通りにCI経由でデプロイしてたらデプロイが失敗してました。

.nvmrcにバージョンを記載するやり方でバージョン指定をしていましたが、突如指定しているバージョンが利用できなくなってフェイルするという事案が発生しました。

参考: Cloud Foundry(IBM Cloud)でNode.jsのバージョン指定【.nvmrc】

no match found for 15.12.0

以下が急に発生したデプロイエラーです。

.nvmcrには確かにv15.12.0で記載してました。

API がファイルの処理を完了するのを待機しています...

アプリをステージングし、ログをトレースしています...
   Downloading nodejs_buildpack...
   Downloaded nodejs_buildpack
   Cell f4f7f92d-7651-4673-be44-27fba5eccf8c creating container for instance 92dbe423-2c84-410c-9721-b2ebe13f7c1f
   Cell f4f7f92d-7651-4673-be44-27fba5eccf8c successfully created container for instance 92dbe423-2c84-410c-9721-b2ebe13f7c1f
   Downloading app package...
   Downloading build artifacts cache...
   Downloaded build artifacts cache (43.6M)
   Downloaded app package (13.4M)
   -----> Nodejs Buildpack version 1.7.48
          **WARNING** buildpack version changed from 1.7.46 to 1.7.48
   -----> Installing binaries
          engines.node (package.json): unspecified
          engines.npm (package.json): unspecified (use default)
          **WARNING** Using the node version specified in your .nvmrc See: http://docs.cloudfoundry.org/buildpacks/node/node-tips.html
          **ERROR** Unable to install node: no match found for 15.12.0 in [10.24.0 10.24.1 12.22.0 12.22.1 14.16.0 14.16.1 15.13.0 15.14.0]
   Failed to compile droplet: Failed to run all supply scripts: exit status 14
   Exit status 223
   Cell f4f7f92d-7651-4673-be44-27fba5eccf8c stopping instance 92dbe423-2c84-410c-9721-b2ebe13f7c1f
   Cell f4f7f92d-7651-4673-be44-27fba5eccf8c destroying container for instance 92dbe423-2c84-410c-9721-b2ebe13f7c1f
アプリケーションのステージング時にエラーが発生しました: App staging failed in the buildpack compile phase
失敗

特に何も記載の変更はしてなく、 急に15.12.0が使えなくなるという。。 こんなことあるんですね。

buildpacksの指定

結局前にやったBuildpacksの指定をするのとpackage.jsonに指定をすることで回避ができました。

参考: Cloud Foundry(IBM Cloud)でNode.jsの最新バージョンを利用する

manifest.yml
applications:
 - name: My-APP
   random-route: true
   memory: 128M
   command: npm start
   buildpacks:
    - https://github.com/cloudfoundry/nodejs-buildpack

package.jsonでバージョン固定にすると今回みたいな事象が起こるかも知れないなと思い、最新の一つ前くらいを指定して、それ以上という指定の仕方にするようにしました。

package.json
  "engines": {
    "node": ">=15.0.0"
  },  

nodejs-buildpackの現状の最新を見ると16.1.0まで対応してるっぽいので最新版を使えそうです。

//省略

-----> Installing node 16.1.0
          Download [https://buildpacks.cloudfoundry.org/dependencies/node/node_16.1.0_linux_x64_cflinuxfs3_aebbbe59.tgz]
          Using default npm version: 7.11.2

デプロイすると16.1.0がインストールされてました。

まとめ

特定のNode.jsのバージョン固定で指定しているかつBuildpacksの指定をしていない状態で発生する問題なのかもしれません。

Cloud Foundry側で自動的に読み込むbuildpacksのバージョンに対応しているNode.jsのバージョンと、手元で指定したNode.jsのバージョンの食い違いが発生するといった感じでしょうか。

他のPaaSなどを使ってても出会ったことがない初めてのケースでビビりました。

15.0.0などの固定ではなく、>=15.0.0などの指定にした方が無難ですね。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0