Skip to content

Troubleshooting

This document lists some methods that can be used to debug the various components of SF-Operator.

  1. OC Debugging
  2. go-delve
  3. Checking service name resolution

OC Debugging

A good way to debug pods is to use the oc debug command.

The debug command makes an exact copy of the pod passed as argument. It will then start a shell session as any user if specified.

Examples

oc debug <container to copy>
oc debug <container to copy> --as-root
oc debug <container to copy> --as-user=<username>

go-delve

Delve is a Go debugger. Follow this documentation to install it.

Example debugging session

Let's assume an error is occuring in the function DeployLogserver, and to be more precise when the function UpdateR is called within DeployLogServer.

To check calls and analyze code:

# in that step, we assume that a SF resource has been created beforehand, and we are doing a re-run
# of the sf-operator in dev mode.
dlv debug ./main.go --namespace sf

With delve running, we can add breakpoints like this:

# this will add a breakpoint in line 272
break controllers/logserver_controller.go:272

# if you want to analyze the whole function, you can do:
break DeployLogserver

Then after setting the breakpoint, we can just add:

continue

Short cheat sheet:

# shows local variables
locals

# show what "annotations" variable contains
print annotations

# show current step/code
list (alias l)

# overwrite variable
set annotations = <something>

# call function, eg.:
call r.Client.Status().Update(ctx, &cr)

Please read delve's documentation for further details.

Checking service name resolution

Normally, if the service is headless, all containers in the cluster should be able to resolve the service's IP address, or even resolve the service's pod IP address. You can check that name resolution is working properly by running these commands:

kubectl exec -it mariadb-0 -- bash -c "host zookeeper-0.zookeeper-headless.default.svc.cluster.local"
kubectl exec -it mariadb-0 -- bash -c "host zuul-executor-0.zuul-executor-headless.default.svc.cluster.local"
kubectl exec -it mariadb-0 -- bash -c "host zuul-executor-0.zuul-executor-headless"