Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. Debugging Serverless applications
You can use a variety of methods to troubleshoot a Serverless application.
5.1. Checking terminal output Copier lienLien copié sur presse-papiers!
You can check your deploy command output to see whether deployment succeeded or not. If your deployment process was terminated, you should see an error message in the output that describes the reason why the deployment failed. This kind of failure is most likely due to either a misconfigured manifest or an invalid command.
Procedure
Open the command output on the client where you deploy and manage your application. The following example is an error that you might see after a failed
oc applycommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This output indicates that you must configure the route traffic percent to be equal to 100.
5.2. Checking pod status Copier lienLien copié sur presse-papiers!
You might need to check the status of your Pod object to identify the issue with your Serverless application.
Procedure
List all pods for your deployment by running the following command:
oc get pods
$ oc get podsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE configuration-example-00001-deployment-659747ff99-9bvr4 2/2 Running 0 3h configuration-example-00002-deployment-5f475b7849-gxcht 1/2 CrashLoopBackOff 2 36s
NAME READY STATUS RESTARTS AGE configuration-example-00001-deployment-659747ff99-9bvr4 2/2 Running 0 3h configuration-example-00002-deployment-5f475b7849-gxcht 1/2 CrashLoopBackOff 2 36sCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the output, you can see all pods with selected data about their status.
View the detailed information on the status of a pod by running the following command:
Example output
oc get pod <pod_name> --output yaml
$ oc get pod <pod_name> --output yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the output, the
conditionsandcontainerStatusesfields might be particularly useful for debugging.
5.3. Checking revision status Copier lienLien copié sur presse-papiers!
You might need to check the status of your revision to identify the issue with your Serverless application.
Procedure
If you configure your route with a
Configurationobject, get the name of theRevisionobject created for your deployment by running the following command:oc get configuration <configuration_name> --output jsonpath="{.status.latestCreatedRevisionName}"$ oc get configuration <configuration_name> --output jsonpath="{.status.latestCreatedRevisionName}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can find the configuration name in the
Route.yamlfile, which specifies routing settings by defining an OpenShiftRouteresource.If you configure your route with revision directly, look up the revision name in the
Route.yamlfile.Query for the status of the revision by running the following command:
oc get revision <revision-name> --output yaml
$ oc get revision <revision-name> --output yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow A ready revision should have the
reason: ServiceReady,status: "True", andtype: Readyconditions in its status. If these conditions are present, you might want to check pod status or Istio routing. Otherwise, the resource status contains the error message.
5.4. Checking Ingress status Copier lienLien copié sur presse-papiers!
You might need to check the status of your Ingress to identify the issue with your Serverless application.
Procedure
Check the IP address of your Ingress by running the following command:
oc get svc -n istio-system istio-ingressgateway
$ oc get svc -n istio-system istio-ingressgatewayCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
istio-ingressgatewayservice is theLoadBalancerservice used by Knative.If there is no external IP address, run the following command:
oc describe svc istio-ingressgateway -n istio-system
$ oc describe svc istio-ingressgateway -n istio-systemCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command prints the reason why IP addresses were not provisioned. Most likely, it is due to a quota issue.
5.5. Checking route status Copier lienLien copié sur presse-papiers!
In some cases, the Route object has issues. You can check its status by using the OpenShift CLI (oc).
Procedure
View the status of the
Routeobject with which you deployed your application by running the following command:oc get route <route_name> --output yaml
$ oc get route <route_name> --output yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Substitute
<route_name>with the name of yourRouteobject.The
conditionsobject in thestatusobject states the reason in case of a failure.
5.6. Checking Ingress and Istio routing Copier lienLien copié sur presse-papiers!
Sometimes, when Istio is used as an Ingress layer, the Ingress and Istio routing have issues. You can see the details on them by using the OpenShift CLI (oc).
Procedure
List all Ingress resources and their corresponding labels by running the following command:
oc get ingresses.networking.internal.knative.dev -o=custom-columns='NAME:.metadata.name,LABELS:.metadata.labels'
$ oc get ingresses.networking.internal.knative.dev -o=custom-columns='NAME:.metadata.name,LABELS:.metadata.labels'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME LABELS helloworld-go map[serving.knative.dev/route:helloworld-go serving.knative.dev/routeNamespace:default serving.knative.dev/service:helloworld-go]
NAME LABELS helloworld-go map[serving.knative.dev/route:helloworld-go serving.knative.dev/routeNamespace:default serving.knative.dev/service:helloworld-go]Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this output, labels
serving.knative.dev/routeandserving.knative.dev/routeNamespaceindicate theRoutewhere the Ingress resource resides. YourRouteand Ingress should be listed.If your Ingress does not exist, the route controller assumes that the
Revisionobjects targeted by yourRouteorServiceobject are not ready. Proceed with other debugging procedures to diagnoseRevisionreadiness status.If your Ingress is listed, examine the
ClusterIngressobject created for your route by running the following command:oc get ingresses.networking.internal.knative.dev <ingress_name> --output yaml
$ oc get ingresses.networking.internal.knative.dev <ingress_name> --output yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the status section of the output, if the condition with
type=Readyhas the status ofTrue, then Ingress is working correctly. Otherwise, the output contains error messages.If Ingress has the status of
Ready, then there is a correspondingVirtualServiceobject. Verify the configuration of theVirtualServiceobject by running the following command:oc get virtualservice -l networking.internal.knative.dev/ingress=<ingress_name> -n <ingress_namespace> --output yaml
$ oc get virtualservice -l networking.internal.knative.dev/ingress=<ingress_name> -n <ingress_namespace> --output yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow The network configuration in the
VirtualServiceobject must match that of theIngressandRouteobjects. Because theVirtualServiceobject does not expose aStatusfield, you might need to wait for its settings to propagate.