# Troubleshooting

> How to see what a local deployment is running, fix the problems that most often stop olf infra deploy --provider local, and collect evidence for a bug…

Source: https://openlakeforge.dev/docs/guides/troubleshooting/

How to see what a local deployment is running, fix the problems that most
often stop `olf infra deploy --provider local`, and collect evidence for a bug
report. Cloud-specific problems are at the end of
[Deploy to AWS](https://openlakeforge.dev/docs/guides/cloud/deploy-to-aws/#troubleshooting) and
[Deploy to Azure](https://openlakeforge.dev/docs/guides/cloud/deploy-to-azure/#troubleshooting).

Most fixes end the same way: `olf infra deploy` reconciles what exists, so running it
again is safe.

```bash
olf infra deploy --provider local
```

## Check the deployment

```bash
olf infra status --provider local
```

| Part | Shows |
| --- | --- |
| A note, when sign-in is off | `Authentication is off.`, plus the OpenMetadata login on Full |
| `URLs` | One line per service route |
| `Pods`, `Services`, `PVCs` | One block for `olf-system`, then one per stage namespace (`olf-dev`, ...) |
| `Certificates not Ready` | With HTTPS, every route certificate that is not issued; `none` when all are |

Start from a pod that is not `Running` or `Completed`, or a PVC that is not
`Bound`. `--stage prod` selects another stage and `--json` prints the same
report as JSON.

Before a first deploy, `olf infra doctor` checks the host without changing anything.
Each line reads `PASS` or `FAIL`:

```bash
olf infra doctor --provider local --phase foundation
```

## Use kubectl

`olf` keeps the cluster's credentials in its own kubeconfig, so your
`~/.kube/config` is untouched. Set it, with the kubectl `olf` manages, in each
shell:

```bash
export KUBECONFIG="$HOME/.openlakeforge/state/local/kubeconfig.yaml"
KUBECTL="$(olf toolchain path kubectl)"
```

Use `$OLF_HOME/state/local/kubeconfig.yaml` if you set `OLF_HOME`. The context
is `kind-openlakeforge-local`.

## Docker is unavailable

`olf init` stops with `Docker engine is not reachable`, or `olf infra deploy` cannot
create the cluster or build images. Start your Docker engine, check that
`docker ps` works, and run `olf` from that same shell.

## The kind cluster was deleted outside olf

After `kind delete cluster`, a Docker data reset or a machine rebuild, the
Terraform state `olf` kept still records a cluster that is gone. `olf infra
deploy` notices that no kind cluster of that name is running, deletes the
foundation and platform state files it names, and creates the cluster again.
`olf infra destroy` does the same and stops, because nothing is left to
destroy. Either way, no manual state cleanup is needed.

## A tool is missing

`olf` provisions Terraform, Helm, kubectl and kind itself, so a missing tool is
usually Docker. `olf infra doctor --provider local --phase foundation` names the
tool and the reason. A managed tool that cannot be downloaded needs network
access to its release host; with `OLF_TOOLCHAIN_MODE=host`, the tool must be on
your `PATH`.

## Ports 80 or 443 are in use

`olf infra deploy` stops before it creates the cluster with
`127.0.0.1:80 already in use` (or `:443`). Find the process, stop it and deploy
again:

```bash
lsof -nP -iTCP:80 -sTCP:LISTEN
```

`olf infra forward` needs its own ports free: 3000, 8080, 8088, 8181, 8585, 8888,
9000 and 9333.

## The cluster is unreachable

```bash
"$KUBECTL" --context kind-openlakeforge-local cluster-info
```

If it fails and `docker ps --filter name=openlakeforge-local` lists no node
containers, the Docker engine was reset. Recreate the cluster, the platform
and your code:

```bash
olf infra deploy --provider local --phase foundation
olf infra deploy --provider local --phase platform
olf infra deploy --provider local --phase artifacts
```

## A pod does not start

Find it in `olf infra status`, then read why. Use the namespace it is listed under:

```bash
POD="<name of the failing pod>"
"$KUBECTL" --context kind-openlakeforge-local describe pod "$POD" -n olf-system
"$KUBECTL" --context kind-openlakeforge-local logs "$POD" -n olf-system
```

For a pod with several containers, add `-c "<container name>"` to `logs`.

## Image pulls are slow or fail

`olf infra deploy` pre-fetches the large images into the kind nodes. After a failed
pull, run that step alone, then deploy again:

```bash
olf infra deploy --provider local --phase prefetch
```

A network that intercepts HTTPS, such as a corporate proxy, makes the pulls
fail with `x509: certificate signed by unknown authority`. Configure your
Docker engine to trust your organization's CA, check that `docker pull` works,
then run the prefetch step again.

## Trino fails at random with Not authorized on WSL2

Queries, dbt models or maintenance runs fail now and then with `Not authorized`
or `Failed to load table`, each time in a different place. On WSL2 this can mean
two services set the clock: Hyper-V time sync and `systemd-timesyncd`. The clock
steps back every half minute. Polaris accepts up to 5 s of skew on the tokens it
issued, so a step larger than that makes it reject a token issued just before
it. `olf infra doctor` lists a second time source under `WSL clock`. WSL takes
its time from Windows, so stop the second service:

```bash
sudo systemctl disable --now systemd-timesyncd
```

## A browser or curl cannot open a service

With the default plain-HTTP routes there is nothing to trust. If the profile sets
`spec.access.tls: local-ca`, the browser must trust the local CA (`olf infra
access trust`). Command-line tools may need `--resolve` for `*.localhost` names. See
[Access the services](https://openlakeforge.dev/docs/guides/local-installation/#access-the-services). With sign-in
on, see [Troubleshoot sign-in](https://openlakeforge.dev/docs/guides/identity/connect-github/#troubleshooting).

## The deployment has drifted

If `olf infra deploy` fails on half-created resources, run it again first. To rebuild
only the platform and keep the cluster:

```bash
olf infra destroy --provider local --phase platform
olf infra deploy --provider local --phase platform
olf infra deploy --provider local --phase artifacts
```

For a clean start, run `olf infra destroy --provider local`, which deletes all data.

### Unexpected Identity Change

A Kubernetes resource whose create failed after the object existed (a rollout
or Job wait that timed out) can be stored with an empty identity. Every later
apply then stops with `Error: Unexpected Identity Change`. `olf infra deploy`
re-imports such `kubernetes_*` resources before each apply and keeps them
tainted, so running it again is the fix. With an `olf` that predates this, or
for a resource it skips (it says so in a warning), remove the resource named in
the error from the state and import it again. Run both from the platform root
`olf` applies, with the same `-var-file` and `-var` values for the import:

```bash
terraform state rm -state="$HOME/.openlakeforge/state/local/platform.tfstate" '<address>'
terraform import -state="$HOME/.openlakeforge/state/local/platform.tfstate" '<address>' '<namespace>/<name>'
```

Terraform 1.12 and later keep the identity on each instance
(`instances[].identity`), not in `attributes`, so editing only `attributes`
does not clear the error.

## Collect diagnostics

`olf infra diagnostics collect` writes a directory of text files for a bug report. A
command that fails is recorded in its own file, and the rest still run:

```bash
export KUBECONFIG="$HOME/.openlakeforge/state/local/kubeconfig.yaml"
olf infra diagnostics collect olf-diagnostics-dev \
  --namespace olf-dev --kube-context kind-openlakeforge-local
```

Repeat it with `--namespace olf-system` for the shared services. The directory
holds host disk and memory, `docker system df`, cluster nodes, pods and events,
and for the namespace its workloads, events, pod descriptions and the last 200
log lines of every container.

:::caution
Logs and descriptions can contain hostnames and project names. Read the files
before you attach them to a public issue.
:::

## Check it worked

```bash
olf infra status --provider local
```

Every pod is `Running` or `Completed`, and
`olf infra e2e run --env local --suite full` ends without an error.

---

<small>Synced from openlakeforge @ `v0.7.5-beta.1` (`8a7bf72`), [docs/guides/troubleshooting.md](https://github.com/OpenLakeForge/openlakeforge/blob/8a7bf7296968594c1676b0f581f7c40c3d31b7ba/docs/guides/troubleshooting.md).</small>
