# ProtectedResourceNotRemoved

A ProtectedResource being deleted may still be on the server; it is Ready=False in phase Deleting.

## Meaning

A ProtectedResource has no deletion policy: deleting it removes the API from the server,
and the server has not done so, or could not be asked to. It did not answer, serves a
contract below 15 (a rollback, or a probe from before an upgrade), refused the call, or the
operator's credential is unusable. A refusal is often the `protected_resources` operation
missing from the operator's grant (`OPERATION_NOT_GRANTED`), or `OUTSIDE_GRANT` when the
server holds the API in an organization the grant no longer covers. The message carries
the cause. The finalizer `nauthera.io/protectedresource`, which goes on before the first
call, holds the resource until the API is gone. A resource never sent carries no finalizer
and goes at once; one the server never accepted, with no `status.etag`, is let go when the
removal is refused for want of the operation, since the server holds nothing of it.

## Impact

The API stays registered, so its `spec.accessTokenTtlSeconds` still bounds tokens issued for
its identifier. The resource and its namespace stay in Terminating.

## Diagnosis

1. `kubectl -n <ns> describe protectedresource <name>` for the cause.
2. `nauthera_operator_server_calls_total{call="DeleteProtectedResource"}` by `code`.
3. `kubectl -n <release-ns> logs deploy/<release>-operator` around the deletion.

## Mitigation

- Fix the cause (see Unreachable, Refused, Unsupported); the removal is retried every five
  minutes, or about once a minute while the server does not answer.
- A grant refusal: add `protected_resources`, or the organization the API is in, to the
  operator's entry in `certManager.grpcTLS.allowedClients`.
- A server below contract 15: upgrade it, or roll the operator back with it.
- Removing the finalizer by hand leaves the API registered on the server, with no manifest
  to change or remove it.

## Escalation

If the server refuses a removal the grant allows, escalate to the identity platform team
with the resource's namespace and name, the condition message and both versions.

---

[Operator failure reasons](https://www.nauthera.io/docs/v1/runbooks/operator) · Generated from [`operator/internal/runbook/conditions.yaml`](https://github.com/nauthera/nauthera-server/blob/main/operator/internal/runbook/conditions.yaml) in nauthera-server.
