> For the complete documentation index, see [llms.txt](https://docs.cennso.com/cennso/cdm/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/cdm/latest/troubleshooting/broken-state.md).

# Broken state

A Mesh enters the Broken phase when one or more critical steps in the installation pipeline fail in a way that prevents automatic recovery.

A "broken state" means the Mesh system cannot continue working or recover by itself due to an unrecoverable error during the installation steps. This situation requires immediate attention and may cause service interruptions.

## Main causes

The most common cause is the loss or corruption of important security secrets (NATS claims secrets). These secrets are essential for the system’s security and operation. If any are missing or invalid, the Mesh cannot function correctly.

## Identifying broken state

The following field values indicate that a Mesh is broken:

- Phase field: `status.atProvider.phase: Broken`
- Step status: One or more steps showing the `Broken` status
- Condition: `type: Ready` with `status: "False"` and `reason: InstallationBroken`
- Error messages: Detailed error information in **status.atProvider.steps[].message**

Example:

   ```yaml
   apiVersion: cdm.cennso.io/v1alpha1
   kind: Mesh
   metadata:
      name: example-mesh-broken
      creationTimestamp: "2025-12-16T10:00:00Z"
   spec:
      forProvider:
         connectionSecretRef:
            name: cdm-connection-secret
            namespace: default
            key: connection-data
         mode: HA
         clusterName: core-cluster-01
         namespace: cdm-system
         resources:
            cpu: "2"
            memory: 4Gi
   status:
      atProvider:
         phase: Broken                                # Mesh is in Broken phase
         steps:
         - name: StepCreateCDMClaims
           status: Broken                                # First step is Broken
           message: CDM Manager API is unreachable or returned invalid response
         - name: CopyResourcesToCoreCluster
           status: Completed
           message: Resources copied successfully
         - name: DeployHelmRelease
           status: Completed
           message: Helm release deployed successfully
       conditions:
         - type: Ready
           status: "False"
           lastTransitionTime: "2025-12-16T10:15:30Z"
           reason: "Unavailable"
           message: "Unavailable"
  ```

## Threats and consequences of the broken state

- **Security risk:** You may see error messages about missing or invalid secrets. The system cannot verify users or services.
- **No simple recovery:** Missing secrets cannot be recreated individually. The system needs the original secrets to work.
- **Service impact:**
  - Some services may continue to run for a short time, but new changes or restarts will fail.
  - No new features or updates can be applied.
  - Automatic recovery from failures is not possible.
  - If the system restarts, it may not start again.
  - There is a risk of losing stored data.

## Recovery procedures

- Restore the missing secret (recommended)

  If you have a backup of the missing secret, restore it as soon as possible. This is the fastest and safest way to recover. There will be no downtime or data loss if the original secret is restored correctly.

  To restore the secret from a file, run:

  ```sh
  kubectl apply -f {SECRET_NAME}.yaml
  ```

  To restore the secret from a cluster backup/snapshot, refer to your backup solution's restoration procedure.

  To verify whether the secret is restored, run:

  ```sh
  kubectl get secret {SECRET_NAME} -n {NAMESPACE}
  ```

  where:

  - **{SECRET_NAME}** - Name of the backup secret to restore
  - **{NAMESPACE}** - Namespace where the secret is stored

- Recreate the Mesh (if no backup exists)

  If you cannot restore the secret, you must delete and recreate the entire Mesh system. As a result:

  - The system will be unavailable during this process (usually 5–15 minutes).
  - All users and applications will need new credentials.
  - Some data may be lost and cannot be recovered.

  To recreate the Mesh, follow these steps:

    1. Document the current configuration:

       ```sh
       kubectl get mesh {MESH-NAME} -o yaml > {MESH_BACKUP}.yaml
       ```

    2. Save the current Mesh configuration to a file.

    3. Delete the broken Mesh. This operation triggers a cleanup.

       ```sh
       kubectl delete mesh <mesh-name>
       ```

    4. Wait for the cleanup to complete. To verify that it did end, run:

       ```sh
       kubectl get mesh <mesh-name>
       ```

     The response should be: `Error from server (NotFound)`

    5. Recreate Mesh from the saved configuration.

## Summary

A broken state is a critical issue that must be resolved quickly to avoid service disruption and data loss. Always try to restore from the backup first. If that is not possible, be prepared for downtime and additional recovery steps. Protect your system by maintaining secure backups and monitoring key resources.
