FN Flows tutorial appears broken (or I'm doing something dumb :<)
I'm attempting to duplicate the FN flow "first flow" tutorial as described here: https://github.com/fnproject/fdk-java/blob/master/docs/FnFlowsUserGuide.md.
My project follows the "primes" example pretty closely in structure and code:
https://imgur.com/a/3TMdQ
And here are my command line operations;
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:37:31$fn apps create flows-example10
Successfully created app: flows-example10
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:38:47$fn deploy --app flows-example10
Deploying patientplatypus/flow-primes to app: flows-example10 at path: /primes
Bumped to version 0.0.14
Building image patientplatypus/flow-primes:0.0.14
Pushing patientplatypus/flow-primes:0.0.14 to docker registry...The push refers to repository [docker.io/patientplatypus/flow-primes]
505f240bdfa8: Layer already exists
895a2a3582de: Layer already exists
5fb388f17d37: Layer already exists
c5e4fcfb11b0: Layer already exists
ae882186dfca: Layer already exists
aaf375487746: Layer already exists
51980d95baf3: Layer already exists
0416abcc3238: Layer already exists
0.0.14: digest: sha256:02d33692c43c7b49387078b82c43812e08841ec9234a944bcd4d7d46e5a483a7 size: 1997
Updating route /primes using image patientplatypus/flow-primes:0.0.14...
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:39:02$fn apps config set flows-example10 COMPLETER_BASE_URL "http://localhost:8081"
flows-example10 updated COMPLETER_BASE_URL with http://localhost:8081
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:39:25$echo 10 | fn call flows-example /primes
Error: Route not found
ERROR: error calling function: status 404
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:39:34$curl -XPOST -d "10" http://localhost:8080/r/flows-example10/primes
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:40:49$curl -XPOST -d "10" http://localhost:8080/r/flows-example10/primes
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:40:57$curl -XPOST -d "10" http://localhost:8080/r/flows-example10/primes --verbose
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /r/flows-example10/primes HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 2
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
< Fn_call_id: 01C9SMEAG9NG8G00RZJ0000013
< Xxx-Fxlb-Wait: 78.389µs
< Date: Thu, 29 Mar 2018 19:41:06 GMT
<
* Connection #0 to host localhost left intact
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:41:04$
As you can see I don't include the line DOCKER_LOCALHOST=$(docker inspect --type container -f '{{.NetworkSettings.Gateway}}' functions), because it fails when I try and run it. If functions is a stand in for something please include that in the documentation, I'm not sure what you're referring to.
patientplatypus:~/Documents/Oracle/DragnDropInfra/fn_flows/testflow:14:41:04$DOCKER_LOCALHOST=$(docker inspect --type container -f '{{.NetworkSettings.Gateway}}' functions)
Error: No such container: functions
However, I did specify that it should be ok to run this on localhost and I still get a 500 error. Would it be possible to point me to a git repo of this example working or let me know what I'm doing wrong? Feel free to email me at [email protected] or [email protected]. Thanks.
Heh - changed title to be less fiesty.
Also, here is an updated function that I made to make the flow as simple as possible.
So this works:
package com.example.fn;
public class HelloFunction {
public String handleRequest(String input) {
String name = (input == null || input.isEmpty()) ? "world" : input;
return "Hello, " + name + "!";
}
}
But this does not:
package com.example.fn;
import com.fnproject.fn.api.flow.Flow;
import com.fnproject.fn.api.flow.Flows;
public class HelloFunction {
public String handleRequest(String input) {
Flow fl = Flows.currentFlow();
// String name = (input == null || input.isEmpty()) ? "world" : input;
return fl.supply(
()->{
String returnVal = "Hello " + input;
return returnVal;
}
)
.thenApply(val -> "hey it worked: " + val)
.get();
}
}
And gives the same error as above. I'm very confused as to why this does not work, as this appears to be the simplest possible flow function, and I'm not sure of how to debug further.
Sounds very similar to what @shaunsmith was seeing. Did you find a solution Shaun?
The setup script has a hardcoded IP instead of using the SEarVER_IP variable calculated before
https://github.com/fnproject/fdk-java/blob/master/examples/async-thumbnails/setup/setup.sh#L89