Use common controller/store for httpTriggerSet and functionReferenceResolver (#390)

This fixes a bug where functionReferenceResolver returned out-of-date function metadata and caused the router to proxy requests to old function pods.

It also uses the go context package to shutdown the controller when the router is shutting down.
This commit is contained in:
Ta-Ching Chen
2017-11-09 07:07:14 -08:00
committed by Soam Vasani
parent 0fd0452e64
commit cce23cf042
4 changed files with 58 additions and 81 deletions
+5 -2
View File
@@ -17,6 +17,7 @@ limitations under the License.
package router
import (
"context"
"fmt"
"testing"
"time"
@@ -58,7 +59,7 @@ func TestRouter(t *testing.T) {
frr.refCache.Set(nfr, rr)
// HTTP trigger set with a trigger for this function
triggers := makeHTTPTriggerSet(fmap, nil, nil, frr, nil)
triggers, _, _ := makeHTTPTriggerSet(fmap, nil, nil, nil)
triggerUrl := "/foo"
triggers.triggers = append(triggers.triggers,
crd.HTTPTrigger{
@@ -75,7 +76,9 @@ func TestRouter(t *testing.T) {
// run the router
port := 4242
go serve(port, triggers)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go serve(ctx, port, triggers, frr)
time.Sleep(100 * time.Millisecond)
// hit the router