Skip to content

HDDS-17695. Add Recon diagnosis framework and deletion design docs - #603

Draft
priyeshkaratha wants to merge 2 commits into
apache:masterfrom
priyeshkaratha:HDDS-17695
Draft

priyeshkaratha wants to merge 2 commits into
apache:masterfrom
priyeshkaratha:HDDS-17695

Conversation

@priyeshkaratha

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR adds two design documents under docs/07-system-internals/08-design/ for a proposed Diagnose feature in Recon.

When a background pipeline such as deletion slows down or stops, finding the cause today means knowing many metrics across OM, SCM and the Datanodes, and which of them only move on the leader. Dashboards show the raw data but don't
say whether a flat line is healthy, an intentional pause or a real stall.

  • Recon Diagnosis Framework (recon-diagnosis-framework.md) describes a framework that lets Recon answer three questions for a chosen service: where it stops making progress, what evidence shows this (each item comes with the PromQL query that produced it), and what to do next. It covers:

    • the REST API GET /api/v1/diagnose, with one URL that serves both browsers and scripts;
    • the DiagnosisProvider plug-in interface;
    • how the verdict and the confidence level are chosen;
    • principles for writing rules;
    • a step-by-step guide to adding a diagnosis for a new service;
    • the UI, cost limits, failure handling, security, configuration and alternatives considered.

    The framework adds no new metrics, RPCs, protobuf messages or RocksDB tables, and Recon keeps no state.

  • Recon Diagnosis: Deletion (recon-diagnosis-deletion.md) describes the first diagnoses built on the framework: OMDeletionService, SCMDeletionService and DatanodeDeletionService. For each one it lists the rules, panels, facts, thresholds and troubleshooting anchors. It also serves as a worked example for adding diagnoses for other services.

What is the link to the Apache Jira?

HDDS-17695

How was this patch tested?

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devmadhuu devmadhuu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @priyeshkaratha for the laying out the design. Few clarifications.


## 2. Problem

Many Ozone features run as background pipelines that cross services: deletion, replication, container balancing, snapshot cleanup. When one slows down or stops, operators struggle to find out why:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here using word "pipelines" confuses the things with ozone pipeline. Try to simplify the language rather AI generated.

- **Name the stalled stage**, with a confidence level and evidence that can be reproduced.
- **Show progress over time.** Graphs over a time window make "stuck" and "progressing slowly" look different.
- **Be easy to find.** Operators start from the Recon navigation bar and pick a diagnosis.
- **One URL for people and scripts.** The same URL opens the page in a browser and returns JSON to `curl`. Runbooks and alerting tools can link to it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who people and what scripts. Statement is not clear.

- **Be easy to find.** Operators start from the Recon navigation bar and pick a diagnosis.
- **One URL for people and scripts.** The same URL opens the page in a browser and returns JSON to `curl`. Runbooks and alerting tools can link to it.
- **Be pluggable.** A new diagnosis needs no framework, endpoint or UI change.
- **Degrade gracefully.** If Prometheus, a metric or SCM is unavailable, only the affected checks become `UNKNOWN`. The rest of the page still renders.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this means "SCM is unavailable", seems design is contradicting itself. If a service or component is unavailable, then why should it be shown as "UNKNOWN", expectation is to give diagnosis ?


1. The operator opens **Diagnose** from the navigation bar.
2. The page lists the diagnoses, grouped by category and then by service.
3. The operator picks one, optionally sets a time window and a Datanode, and clicks **Diagnose**.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be clear on your example , what kind of diagnosis on Datanode ? Is it categorize based on background services or individual components (OM, SCM and datanode) or grouped by features/sub-feature diagnosis. Basic proposed idea is not very clear.

@ArafatKhan2198 ArafatKhan2198 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting together this design! @priyeshkaratha
I think having this feature in Recon would make troubleshooting much easier and save a lot of time during customer escalations. I also like how the framework allows us to add diagnoses for other Ozone services in the future.

I have added some specific questions around some areas, please feel free to close them if you feel they are not relevant.

- **One URL for people and scripts.** The same URL opens the page in a browser and returns JSON to `curl`. Runbooks and alerting tools can link to it.
- **Be pluggable.** A new diagnosis needs no framework, endpoint or UI change.
- **Degrade gracefully.** If Prometheus, a metric or SCM is unavailable, only the affected checks become `UNKNOWN`. The rest of the page still renders.
- **Add no new server-side surface.** No new Ozone metrics, RPCs, protobuf messages, RocksDB tables or persistent state.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we evaluated whether the existing metrics are sufficient to reliably diagnose different failure scenarios? Multiple internal conditions can produce the same metric behaviour. Should we allow additional metrics or RPCs wherever the existing information is insufficient, rather than making this a design constraint?

For example, SCM may stop sending deletion commands because its command queue is full, containers are under-replicated, or the service itself is stuck.
Existing metrics might tell us that commands are not being sent, but not necessarily why.
Why are we restricting ourselves from introducing additional metrics before establishing whether the existing ones are sufficient?


Rules are ordered by pipeline stage. **All** rules run and all their evidence is returned. Then:

1. If any rule is `FAIL`, the first `FAIL` is the verdict (severity `CRITICAL`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What guarantees that the first failing rule represents the actual cause of the problem? A downstream failure can introduce backpressure on upstream services. Should we distinguish between identifying an affected stage and identifying the actual root cause instead of relying on rule order?

The design assumes that the first failing stage is likely to be the cause of the problem.
However, a problem in Datanodes can cause an SCM backlog, which can eventually cause OM to throttle deletion.


1. If any rule is `FAIL`, the first `FAIL` is the verdict (severity `CRITICAL`).
2. Else, if any rule is `WARN`, the first `WARN` is the verdict (severity `WARNING`).
3. Else, if more than half of the rules are `UNKNOWN`, the verdict is `INSUFFICIENT_DATA` (severity `UNKNOWN`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was the 50% UNKNOWN threshold decided? Are all rules equally important? For example, if four out of eight rules are UNKNOWN and those four cover the most critical stages, we would still return HEALTHY with MEDIUM confidence. Should confidence depend on the importance and reliability of the evidence rather than just the number of rules evaluated?

Imagine we have eight rules.
Even if the four unknown rules are the most important checks, Recon would still report the service as healthy. The importance of a rule matters more than simply counting the number of rules that passed.

LIVE --> NM[("Recon node manager")]
```

The split of responsibilities is simple: **providers know the service, the framework knows everything else.** A provider only describes rules, panels and facts. The framework validates the request, runs the provider, enforces the time budget, picks the verdict, caches the result and renders it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recon is a good place to aggregate and present diagnostic information I like this Idea !!

One suggestion, do discard if you think its unnecessary -
Should Recon also maintain detailed knowledge of the internal execution conditions of every Ozone service? How do we ensure that changes in OM, SCM or Datanode behaviour are reflected in the corresponding diagnosis rules? Can we define a clearer ownership model for this diagnostic logic?

- **Handle leaders correctly.** For services that run only on the OM or SCM leader:
- sum counters across instances (`sum(increase(...))`), so progress on any instance counts and a former leader adds nothing;
- take replicated gauges with `max`;
- take run timestamps from the most recent instance (`max(...)`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we handle leadership changes during the diagnosis window? Taking the maximum last-run timestamp across instances could make a service appear active based on the former leader, even when the current leader is not making progress. Should the diagnosis consider the current leader and leadership transitions?

Write one test class per provider, with one test per fault, using `FakePrometheus` (a fake Prometheus that returns fixed values for given query templates) and a mocked `DiagnosisLiveState`:

```java
FakePrometheus prometheus = new FakePrometheus(1800, null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FakePrometheus tests can verify the rule implementation, but how do we validate that the actual metric behaviour in a running Ozone cluster matches our assumptions? Can we introduce integration tests that deliberately create known failure conditions and verify both the observed metrics and the resulting diagnosis?

1. **OM.** Deleted keys go to the `deletedTable` (and deleted directories to the `deletedDirTable`). KeyDeletingService and DirectoryDeletingService, which run only on the OM
leader, pick them up, hand the blocks to SCM, and purge the entries through OM Ratis. Keys still referenced by a snapshot cannot be reclaimed until the snapshot is deleted.
2. **SCM.** The blocks become transactions in the deleted block log. SCMBlockDeletingService, which runs only on the SCM leader, sends delete commands to the Datanodes that hold the replicas. A transaction completes when every replica has acknowledged it. SCM skips transactions whose container is still OPEN or does not have enough replicas.
3. **Datanodes.** Each Datanode receives delete transactions, and its BlockDeletingService removes the block data from disk, then acknowledges on the next heartbeat.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do correct me if I am mistaken here

Is this deletion workflow correct? DeleteBlocksCommandHandler acknowledges deletion after updating the deletion metadata, whereas physical block deletion happens separately through BlockDeletingService. SCM transaction completion does not necessarily indicate that disk space has been reclaimed. Should we distinguish these two stages in the diagnosis?

https://github.com/apache/ozone/blob/d35a048824f2ce64057be77d7bca902c3d69392a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java#L405

| Datanode scope | Only `DatanodeDeletionService` | Datanode state is local; OM and SCM are cluster-wide. |
| Current state | SCM deleted block summary, Recon OM DB `deletedTable`, Recon node manager | Backlogs are more accurate from the source than from a scraped gauge. |
| History | Prometheus counters from OM `DeletingServiceMetrics`, SCM `ScmBlockDeletingServiceMetrics` and Datanode `BlockDeletingServiceMetrics` | Existing metrics; no new ones were added. |
| Leader handling | OM and SCM counters summed, gauges `max`, timestamps `max` | KeyDeletingService and SCMBlockDeletingService run only on the leader. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we verified that every metric being aggregated is actually leader-only? For example, numKeysPurged is incremented inside OMKeyPurgeRequest.validateAndUpdateCache(), which is part of transaction processing. Could summing this metric across OM instances count the same purge operation multiple times?

| `S1-safemode` | SCM readiness | `max(safe_mode_metrics_scm_in_safe_mode)` | FAIL if 1 | `SCM_IN_SAFEMODE` |
| `S2-backlog` | SCM deleted block log | `getDeletedBlockSummary()` over SCM RPC; fallback `max(scm_block_deleting_service_num_block_deletion_transactions)` | Always PASS: reports the backlog | - |
| `S3-dispatch` | SCM -> Datanode dispatch | `..._num_block_deletion_command_sent`, `..._num_skipped_transactions` | SKIPPED if nothing pending. WARN if nothing sent but transactions skipped. FAIL if nothing sent. | `TRANSACTIONS_SKIPPED`, `SCM_NOT_DISPATCHING` |
| `S4-acknowledged` | Datanode acknowledgement | `..._command_success` + `..._command_failure` vs sent; `..._commands_timeout` by Datanode | SKIPPED if nothing sent. FAIL if under 10% acknowledged; names Datanodes with timeouts. | `DATANODE_UNRESPONSIVE` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose SCM generates 10,000 deletion commands towards the end of the diagnosis window.

The Datanodes have acknowledged only 500 of them when the diagnosis runs, but acknowledge the remaining commands shortly afterwards.

Proposed verdict - DATANODE_UNRESPONSIVE

The Datanodes may be working normally. The rule simply has not given them sufficient time. Should we consider outstanding command age and acknowledgement latency?

6. `collectFacts`, wrapped in `try`/`catch` so it never throws.
7. One private `checkX(ctx)` method per rule.

## 5. Shared thresholds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different clusters have different configurations and workloads.
For example, the proposal assumes that a service which has not run for 900 seconds has potentially stopped.
But what if its configured execution interval is 1,200 seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants