Repository navigation
[cardano-testnet] - Status command #6741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4eb3590
Add dummy status command
palas 40de240
Implement table printing and define types for status command
palas 509f483
Add `ToJSON` instances to output types
palas a225612
Implement human-readable rendering of `StatusReport`
palas c8a7b89
Implement status command
palas 9d4fc9c
Add JSON schema for the status output and check it in CI
palas e80d0af
Add tests for the status command
palas 7bf1454
Add changelog fragment
palas 5aa29b1
Pick the best tip by highest slot, not lowest age
palas 16020da
Address small review comments on the status command
palas d5811a5
Improve exception handling and report why nodes did not answer
palas 05c0e6e
Report why there is no testnet and document the exit codes
palas 4aaf1e0
Test the status exit codes, the STOPPED state and the output of every…
palas e37a89c
Improve consistency of formatting
palas 5d9035e
Address the latest review comments on the status command
palas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
cardano-testnet/.changes/20261020_193638_cardano-testnet_pablo.lamela_status_command.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| description: Added `status` command that checks the status of a testnet created with | ||
| `cardano-testnet`. The output can be either in human readable format or JSON (if | ||
| the `--json` flag is specified). The library also exports the `Testnet.Status.Types`, | ||
| `Testnet.Status.Run` and `Testnet.Status.Parsers` modules, `isProcessAlive` from | ||
| `Testnet.Signal`, `testnetEpochSlots` from `Testnet.Types` and `defaultTestnetDir` | ||
| from `Testnet.Start.Types`. | ||
| kind: | ||
| - feature | ||
| pr: 6741 | ||
| project: cardano-testnet | ||
|
palas marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "https://github.com/IntersectMBO/cardano-node/cardano-testnet/schemas/status.schema.json", | ||
| "title": "cardano-testnet status", | ||
| "description": "Output of 'cardano-testnet status --json': the health of a testnet, found by asking every node in its manifest for its chain tip. The schema is strict: it describes schema version 1 exactly, unknown fields are an error, and any change to the output shape bumps schemaVersion.", | ||
| "type": "object", | ||
| "required": [ | ||
| "schemaVersion", | ||
| "checkedAt", | ||
| "status", | ||
| "exitCode", | ||
| "chainProducingBlocks", | ||
| "bestTip", | ||
| "nodes", | ||
| "noTestnetReason" | ||
| ], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "schemaVersion": { | ||
| "type": "integer", | ||
| "const": 1, | ||
| "description": "Schema version. Any change to the output shape, including new fields or values, bumps it." | ||
| }, | ||
| "checkedAt": { | ||
| "type": "string", | ||
| "format": "date-time", | ||
| "description": "UTC time the check started (ISO-8601)." | ||
| }, | ||
| "status": { | ||
| "type": "string", | ||
| "enum": ["running", "degraded", "stalled", "stopped", "no-testnet"], | ||
| "description": "State of the whole network. \"running\": every node is ok. \"degraded\": some nodes are ok, but not all. \"stalled\": some nodes answer, but none is ok. \"stopped\": no node answers. \"no-testnet\": there is no manifest in the directory." | ||
| }, | ||
| "noTestnetReason": { | ||
| "description": "Why there is no testnet, when the status is \"no-testnet\". \"dir-missing\": the directory does not exist. \"not-ready\": it has genesis files but no manifest: the testnet is still starting, or it never became ready. \"not-a-testnet-dir\": it is not the output directory of a testnet. Null for any other status.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "type": "string", "enum": ["dir-missing", "not-ready", "not-a-testnet-dir"] } | ||
| ] | ||
| }, | ||
| "exitCode": { | ||
| "type": "integer", | ||
| "enum": [0, 3, 4, 5], | ||
| "description": "Exit code of the command: 0 for \"running\" and \"degraded\", 3 for \"stalled\", 4 for \"stopped\", 5 for \"no-testnet\"." | ||
| }, | ||
| "chainProducingBlocks": { | ||
| "type": "boolean", | ||
| "description": "True when the exit code is 0: the status is \"running\" or \"degraded\"." | ||
| }, | ||
| "bestTip": { | ||
| "description": "The newest tip of all nodes: the one with the highest slot. Null when no node answered with a tip.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "$ref": "#/$defs/tip" } | ||
| ] | ||
| }, | ||
| "nodes": { | ||
| "type": "array", | ||
| "description": "One entry per node, in the order of the manifest. Empty for \"no-testnet\".", | ||
| "items": { | ||
| "type": "object", | ||
| "required": ["name", "role", "pid", "pidAlive", "state", "tip", "error"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "description": "Node name, as in the manifest." | ||
| }, | ||
| "role": { | ||
| "type": "string", | ||
| "enum": ["spo", "relay"], | ||
| "description": "\"spo\" for stake pool operators, \"relay\" for relay nodes, as in the manifest." | ||
| }, | ||
| "pid": { | ||
| "description": "OS process ID from the manifest, or null when the manifest has none.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "type": "integer" } | ||
| ] | ||
| }, | ||
| "pidAlive": { | ||
| "description": "Whether a process with this pid exists, or null when that is unknown: no pid, or Windows.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "type": "boolean" } | ||
| ] | ||
| }, | ||
| "state": { | ||
| "type": "string", | ||
| "enum": ["ok", "stalled", "unreachable", "down"], | ||
| "description": "\"ok\": it answers, and its tip is fresh. \"stalled\": it answers, but its tip is too old, or it has no blocks yet. \"unreachable\": it does not answer, but its process may be alive. \"down\": it does not answer, and its process is gone." | ||
| }, | ||
| "tip": { | ||
| "description": "The node's tip, or null when it did not answer with one.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "$ref": "#/$defs/tip" } | ||
| ] | ||
| }, | ||
| "error": { | ||
| "description": "Why the node did not answer (an error, or no answer in time), or null when it answered.", | ||
| "oneOf": [ | ||
| { "type": "null" }, | ||
| { "type": "string" } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "$defs": { | ||
| "tip": { | ||
| "type": "object", | ||
| "required": ["slot", "blockNo", "hash", "ageSeconds"], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "slot": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "description": "Slot number of the tip." | ||
| }, | ||
| "blockNo": { | ||
| "type": "integer", | ||
| "minimum": 0, | ||
| "description": "Block number of the tip." | ||
| }, | ||
| "hash": { | ||
| "type": "string", | ||
| "pattern": "^[0-9a-f]{64}$", | ||
| "description": "Block header hash of the tip, hex-encoded." | ||
| }, | ||
| "ageSeconds": { | ||
| "type": "number", | ||
| "description": "Seconds from the start of the tip's slot until the node answered." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.