openfaas

Openfaas function keeps returning the same result even after redeploying


I built a little Openfaas function using the tutorial. After initial build and deployment, it worked just fine and returned {"status":"done"}, just as I intended.

After the initial successful run, I made changes to the index.js handler (it's a node project). I rebuilt and redeployed using the following commands:

faas-cli build -f license.yml && faas-cli deploy -f license.yml

and invoke the function using the following command:

curl 127.0.0.1:8080/function/license -H 'Content-Type: application/json' --data-binary '{"hosts":["YYYXXXAAABBBCCC"]}'

In stead of returning a "status" object (see above), it should return a "licenseKey". However, no matter how often I build/deploy this function, it keeps returning the original object.

What do I have to do to make Openfaas use the new code?


Solution

  • I believe I made a rookie mistake. In stead of using handler.js as the main file I used index.js. I probably had a leftover handler.js from running the tutorial, but mv index.js handler.js did the trick (after rebuilding and deploying, of course).