> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/cennso-db/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/cennso/cennso-db/latest/troubleshooting/crossplane-trace.md).

# Get traces for Crossplane reconciliation

If a Custom Resource of the Cennso Database extension, such as the database operator or the database instance, is not ready after applying to the cluster, you can use the [`crossplane`](https://docs.crossplane.io/cli/latest/) utility to get tracing of the events related to this resource.

You can download this utility using the following command:

```bash
mkdir crossplane
curl -sL "https://raw.githubusercontent.com/crossplane/crossplane/main/install.sh" > ./crossplane/get_crossplane_cli.sh
sudo chmod +x ./crossplane/get_crossplane_cli.sh
./get_crossplane_cli.sh
```

The following section explains how to inspect Crossplane's reconciliation of a resource tree and check why a composite resource is stuck in a pending or error state.

## Step-by-step trace

The `crossplane beta trace` command shows the tree of resources that Crossplane creates for a Custom Resource, together with the status of every resource in the tree. To trace a Custom Resource, execute the following steps:

1. List the resources you are interested in. Use the resource name that corresponds to the Custom Resource:

   | Custom Resource | Resource name | Scope |
   |---|---|---|
   | `DBOperator` | `xdboperators.db.contrib.cennso.com` | Cluster |
   | `DBInstance` | `xdbinstances.db.contrib.cennso.com` | Cluster |
   | `DBSchema` | `xdbschemas.db.contrib.cennso.com` | Cluster |
   | `DBUser` | `xdbusers.db.contrib.cennso.com` | Cluster |
   | `DBBackup` | `xdbbackups.db.contrib.cennso.com` | Cluster |
   | `DBTLSCertificate` | `xdbtlscertificates.db.contrib.cennso.com` | Cluster |
   | `PostgreSQLOperator` | `postgresqloperators.db.contrib.cennso.com` | Namespaced |
   | `PostgreSQLInstance` | `postgresqlinstances.db.contrib.cennso.com` | Namespaced |
   | `PostgreSQLSchema` | `postgresqlschemas.db.contrib.cennso.com` | Namespaced |
   | `PostgreSQLUser` | `postgresqlusers.db.contrib.cennso.com` | Namespaced |
   | `PostgreSQLBackup` | `postgresqlbackups.db.contrib.cennso.com` | Namespaced |

   To get the list of all Cluster-scoped resources, use the following command:

   ```bash
   kubectl get xdboperators.db.contrib.cennso.com
   ```

   To get the list of all Namespace-scoped resources, use the following command:

   ```bash
   kubectl get postgresqloperators.db.contrib.cennso.com -n {NAMESPACE}
   ```

2. Run the trace command for the resource you are interested in and capture the logs of events, references, and status updates.

   To trace a Cluster-scoped resource, use the following command:

   ```bash
   crossplane beta trace xdboperators.db.contrib.cennso.com {DB-RESOURCE-NAME}
   ```

   To trace a Namespaced resource, use the following command:

   ```bash
   crossplane beta trace postgresqloperators.db.contrib.cennso.com {DB-RESOURCE-NAME} -n {NAMESPACE}
   ```

3. Check the status of the objects created by the composition. If there are errors in the output of the `crossplane` command above, you can find more information by inspecting the object that returned an error.

   - A Cluster-scoped resource creates Cluster-scoped objects. To inspect such an object, use the following command:

      ```bash
      kubectl get object {DB-OBJECT-RESOURCE-NAME} -o jsonpath='{.status.conditions}' | jq
      ```

   - A Namespaced resource creates Namespaced objects in the namespace of the Custom Resource. To inspect such an object, use the following command:

      ```bash
      kubectl get objects.kubernetes.m.crossplane.io {DB-OBJECT-RESOURCE-NAME} -n {NAMESPACE} -o jsonpath='{.status.conditions}' | jq
      ```
