serving icon indicating copy to clipboard operation
serving copied to clipboard

Full trace missing when activation required

Open objectiser opened this issue 7 years ago • 12 comments

In what area(s)?

/area monitoring

What version of Knative?

v0.5.0-781-g1f437558 (Misleading) -> actually related to master sha https://github.com/knative/serving/commit/1f4375582329b8a30c21c7dd3f49147de0d86376 from 22nd July.

Expected Behavior

When an initial request arrives, resulting activator/auto-scaler being involved, the trace should include the ingress gateway, activator, auto-scaler and finally the service.

Actual Behavior

Only the ingress gateway and activator spans are shown. The next request then has the ingress gateway and the service (i.e. missing out the activator/auto-scaler) as the service is already available.

The first image shows the traces for the istio-ingressgateway service, most recent first - so first request just goes to the activator, and second request goes to the service. The first request should include auto-scaler and service aswell.

knative-tracing-1

The second image shows the traces involving the service - the bottom trace in the list being the request that was routed to the already active service. The next 3 traces I assume relate to knative scaling the pod down.

knative-tracing-2

Steps to Reproduce the Problem

Followed the instructions to deploy the master branch of knative/serving: https://github.com/knative/serving/blob/master/DEVELOPMENT.md

Deployed the Jaeger operator: https://github.com/jaegertracing/jaeger-operator#getting-started

Created a Jaeger instance:

kubectl apply -R -f config/monitoring/tracing/jaeger/memory/ -f config/monitoring/tracing/jaeger/105-zipkin-service.yaml

Access the Jaeger UI: https://knative.dev/docs/serving/accessing-traces/

Deploy an example service and invoke multiple times.

objectiser avatar Jul 22 '19 11:07 objectiser

@objectiser we've recently released v0.7 so you're version is quite old. Do you mind rechecking on the latest?

markusthoemmes avatar Jul 22 '19 12:07 markusthoemmes

Reading through the whole writeup: I think the autoscaler spans are red herrings. They are not on the actual request path. The spans you're seeing are likely the scrape calls from the autoscaler.

markusthoemmes avatar Jul 22 '19 12:07 markusthoemmes

@markusthoemmes This is strange - output from git describe -dirtyis showing an old label, but I'm actually on master 1f4375582329b8a30c21c7dd3f49147de0d86376.

I think the autoscaler spans are red herrings. They are not on the actual request path. The spans you're seeing are likely the scrape calls from the autoscaler.

Ok - but then the issue is that there is no trace representing the request that activated the service. So still seems to be a problem.

objectiser avatar Jul 22 '19 12:07 objectiser

Please try with newer version. Real tracing was added in version 0.6.

On Mon, Jul 22, 2019 at 5:08 AM Gary Brown [email protected] wrote:

@markusthoemmes https://github.com/markusthoemmes This is strange - output from git describe -dirtyis showing an old label, but I'm actually on master 1f43755 https://github.com/knative/serving/commit/1f4375582329b8a30c21c7dd3f49147de0d86376 .

I think the autoscaler spans are red herrings. They are not on the actual request path. The spans you're seeing are likely the scrape calls from the autoscaler.

Ok - but then the issue is that there is no trace representing the request that activated the service. So still seems to be a problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/knative/serving/issues/4871?email_source=notifications&email_token=AAF2WX76BJLG3VBDP4UMTQLQAWPKPA5CNFSM4IFX3NS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2PWX6A#issuecomment-513764344, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF2WX2HPHSB7BHNXJ2C4CDQAWPKPANCNFSM4IFX3NSQ .

vagababov avatar Jul 22 '19 18:07 vagababov

@vagababov Was tested with master HEAD - the git describe -dirty command is misleading as tags don't appear to be applied to master since v0.5.0. Would suggest changing the bug template,

Tried the same testing against released 0.7.0 version and got the same results. Steps to reproduce:

minikube start --vm-driver kvm2 --memory 16384 --cpus 8
kubectl apply --filename https://raw.githubusercontent.com/knative/serving/v0.7.0/third_party/istio-1.1.7/istio-crds.yaml && curl -L https://raw.githubusercontent.com/knative/serving/v0.7.0/third_party/istio-1.1.7/istio.yaml   | sed 's/LoadBalancer/NodePort/'   | kubectl apply --filename -
kubectl label namespace default istio-injection=enabled

kubectl apply --selector knative.dev/crd-install=true --filename https://github.com/knative/serving/releases/download/v0.7.0/serving.yaml
kubectl apply --filename https://github.com/knative/serving/releases/download/v0.7.0/serving.yaml --selector networking.knative.dev/certificate-provider!=cert-manager --filename https://github.com/knative/serving/releases/download/v0.7.0/monitoring-tracing-zipkin-in-mem.yaml

Then deploy an example:

export KNATIVE_ADDR=$(minikube ip):$(kubectl get svc istio-ingressgateway --namespace istio-system --output 'jsonpath={.spec.ports[?(@.port==80)].nodePort}')
kubectl apply --filename service.yaml

where service.yaml is

apiVersion: serving.knative.dev/v1alpha1 # Current version of Knative
kind: Service
metadata:
  name: helloworld-go # The name of the app
  namespace: default # The namespace the app will use
spec:
  runLatest:
    configuration:
      revisionTemplate:
        spec:
          container:
            image: gcr.io/knative-samples/helloworld-go # The URL to the image of the app
            env:
              - name: TARGET # The environment variable printed out by the sample app
                value: "Go Sample v1"

then after waiting a while, run the following command once to activate the service and after a short delay run it again.

curl -H "Host: helloworld-go.default.example.com" http://$KNATIVE_ADDR

Access the zipkin UI using the instructions here: https://knative.dev/docs/serving/accessing-traces/

knative-zipkin-0 7 0

These traces are in reverse order - the bottom trace related to the first request - as you can see if only involves the ingress gw and the activator. The second request (second from bottom trace) is correct, showing ingress gw and the hello-go service.

The remaining trace instances are related to the service being scaled down I believe - they occur after about a minute.

objectiser avatar Jul 23 '19 09:07 objectiser

/assign @greghaynes Greg, could you please take a look and see why the trace is not propagated?

vagababov avatar Jul 23 '19 16:07 vagababov

Interesting - this is new to me, last I tried this tracing was a while ago and the spans were being propagated. We likely messed something up where we are either losing a request context somewhere or are not properly creating our tracing transport. I'll have a look.

greghaynes avatar Jul 23 '19 17:07 greghaynes

Looking into this -- @objectiser, I just want to confirm that you have tracing disabled when you see the missing traces? I was able to recreate your same behavior when tracing is disabled, but when tracing is enabled we appear to get the full trace as expected.

One thing I noticed is that if we remove the ochttp.Transport wrapper from the transport, then the traces behave correctly when tracing is disabled.

trace
	proxy.Transport = a.transport

vs.

	proxy.Transport = &ochttp.Transport{
		Base: a.transport,
	}

I'm still trying to understand exactly what that wrapper does, but when tracing is disabled I wonder if it uses our config-tracing.yaml to disable all tracing?

bvennam avatar Aug 06 '19 20:08 bvennam

@beemarie good point. We should probably only use the ochhttp.Transport conditionally if tracing is enabled. I think you've done that in your recent queue-proxy change, the activator however unconditionally uses it.

https://github.com/knative/serving/blob/c6860bf7c0663ddbf71d8fa3b48cbfbd9b54c205/pkg/activator/handler/handler.go#L87-L89

https://github.com/knative/serving/blob/c6860bf7c0663ddbf71d8fa3b48cbfbd9b54c205/pkg/activator/handler/handler.go#L230-L232

markusthoemmes avatar Aug 07 '19 06:08 markusthoemmes

@beemarie I didn't specifically change any configuration, so I had whatever the default is. However not clear what "tracing disabled" means in this case, as clearly tracing is being generated?

objectiser avatar Aug 07 '19 07:08 objectiser

We have "internal" tracing as well, where we get more fine-grained traces to see where time is spent etc. That's turned off by default, however the activator still unconditionally instruments the HTTP transport with tracing stuff. Maybe that somehow breaks Istio's generation of traces or something, if we don't report these traces ourselves?

markusthoemmes avatar Aug 07 '19 08:08 markusthoemmes

It seems like the trace context is not being propagated if this fine grained tracing is turned off. So if the two can be separated, so debug spans only created when enabled, but trace context always propagated, then that should be fine.

objectiser avatar Aug 07 '19 08:08 objectiser