From 2ba66afb9fd339e326f65aa7cecbc8c2907cf697 Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Tue, 2 Jul 2019 00:08:29 +0800 Subject: [PATCH] Fix Istio-proxy cannot collect HTTP-level information (#1209) --- pkg/executor/newdeploy/newdeploy.go | 14 ++++++++------ pkg/executor/poolmgr/funcwatcher.go | 11 +++-------- pkg/executor/poolmgr/gp.go | 19 ++++++++++++++++--- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/pkg/executor/newdeploy/newdeploy.go b/pkg/executor/newdeploy/newdeploy.go index c723932c..780f8728 100644 --- a/pkg/executor/newdeploy/newdeploy.go +++ b/pkg/executor/newdeploy/newdeploy.go @@ -217,6 +217,13 @@ func (deploy *NewDeploy) getDeploymentSpec(fn *fv1.Function, env *fv1.Environmen }, }, }, + // https://istio.io/docs/setup/kubernetes/additional-setup/requirements/ + Ports: []apiv1.ContainerPort{ + { + Name: "http-env", + ContainerPort: int32(8888), + }, + }, Resources: resources, }, env.Spec.Runtime.Container), }, @@ -362,15 +369,10 @@ func (deploy *NewDeploy) createOrGetSvc(deployLabels map[string]string, svcName Spec: apiv1.ServiceSpec{ Ports: []apiv1.ServicePort{ { - Name: "runtime-env-port", + Name: "http-env", Port: int32(80), TargetPort: intstr.FromInt(8888), }, - { - Name: "fetcher-port", - Port: int32(8000), - TargetPort: intstr.FromInt(8000), - }, }, Selector: deployLabels, Type: apiv1.ServiceTypeClusterIP, diff --git a/pkg/executor/poolmgr/funcwatcher.go b/pkg/executor/poolmgr/funcwatcher.go index a90bae27..d9ced968 100644 --- a/pkg/executor/poolmgr/funcwatcher.go +++ b/pkg/executor/poolmgr/funcwatcher.go @@ -106,20 +106,15 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie Type: apiv1.ServiceTypeClusterIP, Ports: []apiv1.ServicePort{ // Service port name should begin with a recognized prefix, or the traffic will be - // treated as TCP traffic. (https://istio.io/docs/setup/kubernetes/sidecar-injection.html) - // Originally the ports' name are similar to "http-fetch" and "http-specialize". - // But for istio 0.5.1, istio-proxy return unexpected 431 error with such naming. - // https://github.com/istio/istio/issues/928 - // Workaround: remove prefix - // TODO: prepend prefix once the bug fixed + // treated as TCP traffic. (https://istio.io/docs/setup/kubernetes/additional-setup/requirements/) { - Name: "fetch", + Name: "http-fetcher", Protocol: apiv1.ProtocolTCP, Port: 8000, TargetPort: intstr.FromInt(8000), }, { - Name: "specialize", + Name: "http-env", Protocol: apiv1.ProtocolTCP, Port: 8888, TargetPort: intstr.FromInt(8888), diff --git a/pkg/executor/poolmgr/gp.go b/pkg/executor/poolmgr/gp.go index 92c8d96e..660d6a31 100644 --- a/pkg/executor/poolmgr/gp.go +++ b/pkg/executor/poolmgr/gp.go @@ -276,8 +276,8 @@ func IsIPv6(podIP string) bool { return ip != nil && strings.Contains(podIP, ":") } -func (gp *GenericPool) getSpecializeUrl(podIP string) string { - testUrl := os.Getenv("TEST_SPECIALIZE_URL") +func (gp *GenericPool) getFetcherUrl(podIP string) string { + testUrl := os.Getenv("TEST_FETCHER_URL") if len(testUrl) != 0 { // it takes a second or so for the test service to // become routable once a pod is relabeled. This is @@ -312,7 +312,7 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, metada } // tell fetcher to get the function. - fetcherUrl := gp.getSpecializeUrl(podIP) + fetcherUrl := gp.getFetcherUrl(podIP) gp.logger.Info("calling fetcher to copy function", zap.String("function", metadata.Name), zap.String("url", fetcherUrl)) fn, err := gp.fissionClient. @@ -326,6 +326,8 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, metada gp.logger.Info("specializing pod", zap.String("function", metadata.Name)) + // Fetcher will download user function to share volume of pod, and + // invoke environment specialize api for pod specialization. err = fetcherClient.MakeClient(gp.logger, fetcherUrl).Specialize(ctx, &specializeReq) if err != nil { return err @@ -396,6 +398,17 @@ func (gp *GenericPool) createPool() error { }, }, }, + // https://istio.io/docs/setup/kubernetes/additional-setup/requirements/ + Ports: []apiv1.ContainerPort{ + { + Name: "http-fetcher", + ContainerPort: int32(8000), + }, + { + Name: "http-env", + ContainerPort: int32(8888), + }, + }, }, gp.env.Spec.Runtime.Container), }, ServiceAccountName: "fission-fetcher",