怒Mは思いつきでモノを言う

やったことメモなどなど

Fn Projectについて調べて見た。③

前回はfn invokeで失敗しまいました。

do-m-gatoru.hatenablog.com

原因はFn Serverのバージョンが古かった

調べても同じ様なバグ報告がなかったので、環境がおかしいと考えました。
Fn CLIbrewを使うことでアップデートできますが、Fn Serverのバージョンは7月にインストールした時点のバージョンから変わりません。
Fn CLIの内容を改めて確認しみました。

$ fn help
Fn Command Line Tool  -  Version 0.5.15
                                 
ENVIRONMENT VARIABLES
  FN_API_URL      Fn server address
  FN_REGISTRY     Docker registry to push images to, use username only to push to Docker Hub - [[registry.hub.docker.com/]USERNAME]
               
GENERAL COMMANDS
  version         Display Fn CLI and Fn Server versions
  help, h         Shows a list of commands or help for one command
  
DEVELOPMENT COMMANDS
  build, bu            Build function version
  bump, bm             Bump function version
  call, cl             Prompts for migration.
  deploy, dp           Deploys a function to the functions server (bumps, build, pushes and updates functions and/or triggers).
  init, in             Create a local func.yaml file
  invoke, iv           Invoke a remote function
  migrate, m           Migrate a local func.yaml file to the latest version
  push, p              Push function to docker registry
  
MANAGEMENT COMMANDS
  config, cf           Set configuration for an object
  create, c            Create a new object
  delete, d            Delete an object
  get, g               Get an object to retrieve its information
  inspect, i           Retrieve properties of an object
  list, ls             Return a list of created objects
  unset, un            Unset elements of a created object
  update, up           Update a created object
  use, u               Select context for further commands
  
SERVER COMMANDS
  build-server         Build custom Fn server
  start                Start a local Fn server
  stop                 Stop a function server
                
GLOBAL OPTIONS
  --context value      Use --context to select context configuration file
  --registry value     Use --registry to select registry
  --verbose, -v        Use --verbose to enable verbose mode for debugging
  --help, -h           show help
  --version            Display version
                         
FURTHER HELP:  See 'fn <command> --help' for more information about a command.
                       
LEARN MORE:    https://github.com/fnproject/fn

管理コマンドupdateというのがあるではないですか。
節穴でした。(この時点でServerは0.3.495)

$ fn update server
Using default tag: latest
latest: Pulling from fnproject/fnserver
〜中略〜
Status: Downloaded newer image for fnproject/fnserver:latest
2018/10/11 23:59:08 Process finished gracefully

$ fn version
Client version is latest version: 0.5.15
Server version:  0.3.595

無事に更新ができました。
fn startしてfn invokeを確認します。

$ fn deploy --app myapp --local
Deploying fntest to app: myapp
Bumped to version 0.0.15
Building image fntest:0.0.15 
Updating function fntest using image fntest:0.0.15...

$ fn invoke myapp fntest
Hello, world!

やっと出ました!嬉しい!

Fn の更新手順

Fnを更新する際は以下の順番で更新した方が良いです。

  1. brew upgrade fnでFn CLIを更新
  2. fn update serverで Fn Serverを更新