Skip to content

Commit

Permalink
Merge #55854
Browse files Browse the repository at this point in the history
55854: server,docgen: enhance the API documentation r=taroface a=knz

Informs cockroachdb/docs#8602

This commit makes three changes:

- it extends the API doc generator to recognize
  annotations to distinguish “reserved”, “alpha” and “public” APIs
  and report this level of support in the generated output.

  [Example full output here](https://github.com/knz/cockroach/blob/20201022-nodes/docs/generated/http/full.md)

- it makes it possible to annotate different levels of support
  for different fields inside a single API payload. This makes
  it possible to document that certain fields of public APIs
  are “reserved”.

- it marks all the APIs as “reserved” except for the following three:

  - `/health` which has been stabilized and is safely documentable.

    [See doc here](https://github.com/knz/cockroach/blob/20201022-nodes/docs/generated/http/full.md#health)

  - `/_status/nodes` ([generated doc](https://github.com/knz/cockroach/blob/20201022-nodes/docs/generated/http/full.md#nodes)) and `/_status/hotranges` ([generated doc](https://github.com/knz/cockroach/blob/20201022-nodes/docs/generated/http/full.md#hotranges)) are marked
    as “alpha” as requested by
    @piyush-singh, to serve as example of how we could
    document an API.

Note that some other API endpoints could probably be marked as “alpha”
but the upcoming release cycle will see the introduction of a new
namespace for public APIs, so we wish to not over-commit at this time.

Release note: None

Co-authored-by: Raphael 'kena' Poss <knz@thaumogen.net>
  • Loading branch information
craig[bot] and knz committed Jan 11, 2021
2 parents e5eddde + cab51fd commit 91a0898
Show file tree
Hide file tree
Showing 20 changed files with 3,887 additions and 1,098 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ bin/.docgen_http: bin/docgen $(PROTOC)
--protoc $(PROTOC) \
--gendoc ./bin/protoc-gen-doc \
--out docs/generated/http \
--protobuf pkg:$(GOGO_PROTOBUF_PATH):$(PROTOBUF_PATH):$(COREOS_PATH):$(GRPC_GATEWAY_GOOGLEAPIS_PATH):$(ERRORS_PATH)
--protobuf pkg:./vendor/github.com:$(GOGO_PROTOBUF_PATH):$(PROTOBUF_PATH):$(COREOS_PATH):$(GRPC_GATEWAY_GOOGLEAPIS_PATH):$(ERRORS_PATH)
touch $@

.PHONY: docs/generated/redact_safe.md
Expand Down
3,913 changes: 3,078 additions & 835 deletions docs/generated/http/full.md

Large diffs are not rendered by default.

Empty file.
30 changes: 30 additions & 0 deletions docs/generated/http/health-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


<a name="cockroach.server.serverpb.HealthRequest"></a>
#### HealthRequest

HealthRequest requests a liveness or readiness check.

A liveness check is triggered via ready set to false. In this mode,
an empty response is returned immediately, that is, the caller merely
learns that the process is running.

A readiness check (ready == true) is suitable for determining whether
user traffic should be directed at a given node, for example by a load
balancer. In this mode, a successful response is returned only if the
node:

- is not in the process of shutting down or booting up (including
waiting for cluster bootstrap);
- is regarded as healthy by the cluster via the recent broadcast of
a liveness beacon. Absent either of these conditions, an error
code will result.

Support status: [public](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| ready | [bool](#bool) | | ready specifies whether the client wants to know whether the target node is ready to receive traffic. If a node is unready, an error will be returned. | [public](#support-status) |


12 changes: 12 additions & 0 deletions docs/generated/http/health-response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


<a name="cockroach.server.serverpb.HealthResponse"></a>
#### HealthResponse

HealthResponse is the response to HealthRequest. It currently does not
contain any information.

Support status: [public](#support-status)



54 changes: 38 additions & 16 deletions docs/generated/http/hotranges-other.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,64 @@
<a name="cockroach.server.serverpb.HotRangesResponse.HotRangesByNodeIdEntry"></a>
#### HotRangesResponse.HotRangesByNodeIdEntry

| Field | Type | Label |
| ----- | ---- | ----- |
| key | [int32](#int32) | |
| value | [HotRangesResponse.NodeResponse](#cockroach.server.serverpb.HotRangesResponse.NodeResponse) | |





| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [int32](#int32) | | | |
| value | [HotRangesResponse.NodeResponse](#cockroach.server.serverpb.HotRangesResponse.NodeResponse) | | | |




<a name="cockroach.server.serverpb.HotRangesResponse.NodeResponse"></a>
#### HotRangesResponse.NodeResponse

| Field | Type | Label |
| ----- | ---- | ----- |
| error_message | [string](#string) | |
| stores | [HotRangesResponse.StoreResponse](#cockroach.server.serverpb.HotRangesResponse.StoreResponse) | repeated |
NodeResponse is a hot range report for a single target node.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| error_message | [string](#string) | | ErrorMessage is set to a non-empty string if this target node was unable to produce a hot range report.<br><br>The contents of this string indicates the cause of the failure. | [alpha](#support-status) |
| stores | [HotRangesResponse.StoreResponse](#cockroach.server.serverpb.HotRangesResponse.StoreResponse) | repeated | Stores contains the hot ranges report if no error was encountered. There is one part to the report for each store in the target node. | [alpha](#support-status) |




<a name="cockroach.server.serverpb.HotRangesResponse.StoreResponse"></a>
#### HotRangesResponse.StoreResponse

| Field | Type | Label |
| ----- | ---- | ----- |
| store_id | [int32](#int32) | |
| hot_ranges | [HotRangesResponse.HotRange](#cockroach.server.serverpb.HotRangesResponse.HotRange) | repeated |
StoreResponse contains the part of a hot ranges report that
pertains to a single store on a target node.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| store_id | [int32](#int32) | | StoreID identifies the store for which the report was produced. | [alpha](#support-status) |
| hot_ranges | [HotRangesResponse.HotRange](#cockroach.server.serverpb.HotRangesResponse.HotRange) | repeated | HotRanges is the hot ranges report for this store on the target node. | [alpha](#support-status) |




<a name="cockroach.server.serverpb.HotRangesResponse.HotRange"></a>
#### HotRangesResponse.HotRange

| Field | Type | Label |
| ----- | ---- | ----- |
| desc | [cockroach.roachpb.RangeDescriptor](#cockroach.roachpb.RangeDescriptor) | |
| queries_per_second | [double](#double) | |
HotRange is a hot range report for a single store on one of the
target node(s) selected in a HotRangesRequest.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| desc | [cockroach.roachpb.RangeDescriptor](#cockroach.roachpb.RangeDescriptor) | | Desc is the descriptor of the range for which the report was produced.<br><br>TODO(knz): This field should be removed. See: https://github.com/cockroachdb/cockroach/issues/53212 | [reserved](#support-status) |
| queries_per_second | [double](#double) | | QueriesPerSecond is the recent number of queries per second on this range. | [alpha](#support-status) |


12 changes: 9 additions & 3 deletions docs/generated/http/hotranges-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
<a name="cockroach.server.serverpb.HotRangesRequest"></a>
#### HotRangesRequest

| Field | Type | Label |
| ----- | ---- | ----- |
| node_id | [string](#string) | |
HotRangesRequest queries one or more cluster nodes for a list
of ranges currently considered “hot” by the node(s).

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| node_id | [string](#string) | | NodeID indicates which node to query for a hot range report. It is posssible to populate any node ID; if the node receiving the request is not the target node, it will forward the request to the target node.<br><br>If left empty, the request is forwarded to every node in the cluster. | [alpha](#support-status) |


14 changes: 10 additions & 4 deletions docs/generated/http/hotranges-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
<a name="cockroach.server.serverpb.HotRangesResponse"></a>
#### HotRangesResponse

| Field | Type | Label |
| ----- | ---- | ----- |
| node_id | [int32](#int32) | |
| hot_ranges_by_node_id | [HotRangesResponse.HotRangesByNodeIdEntry](#cockroach.server.serverpb.HotRangesResponse.HotRangesByNodeIdEntry) | repeated |
HotRangesResponse is the payload produced in response
to a HotRangesRequest.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| node_id | [int32](#int32) | | NodeID is the node that received the HotRangesRequest and forwarded requests to the selected target node(s). | [alpha](#support-status) |
| hot_ranges_by_node_id | [HotRangesResponse.HotRangesByNodeIdEntry](#cockroach.server.serverpb.HotRangesResponse.HotRangesByNodeIdEntry) | repeated | HotRangesByNodeID contains a hot range report for each selected target node ID in the HotRangesRequest. | [alpha](#support-status) |


139 changes: 139 additions & 0 deletions docs/generated/http/nodes-other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@


<a name="cockroach.server.status.statuspb.NodeStatus"></a>
#### NodeStatus

NodeStatus records the most recent values of metrics for a node.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| desc | [cockroach.roachpb.NodeDescriptor](#cockroach.roachpb.NodeDescriptor) | | desc is the node descriptor. | [reserved](#support-status) |
| build_info | [cockroach.build.Info](#cockroach.build.Info) | | build_info describes the `cockroach` executable file. | [alpha](#support-status) |
| started_at | [int64](#int64) | | started_at is the unix timestamp at which the node process was last started. | [alpha](#support-status) |
| updated_at | [int64](#int64) | | updated_at is the unix timestamp at which the node status record was last updated. | [alpha](#support-status) |
| metrics | [NodeStatus.MetricsEntry](#cockroach.server.status.statuspb.NodeStatus.MetricsEntry) | repeated | metrics contains the last sampled values for the node metrics. | [reserved](#support-status) |
| store_statuses | [StoreStatus](#cockroach.server.status.statuspb.StoreStatus) | repeated | store_statuses provides the store status payloads for all the stores on that node. | [reserved](#support-status) |
| args | [string](#string) | repeated | args is the list of command-line arguments used to last start the node. | [reserved](#support-status) |
| env | [string](#string) | repeated | env is the list of environment variables that influenced the node's configuration. | [reserved](#support-status) |
| latencies | [NodeStatus.LatenciesEntry](#cockroach.server.status.statuspb.NodeStatus.LatenciesEntry) | repeated | latencies is a map of nodeIDs to nanoseconds which is the latency between this node and the other node.<br><br>NOTE: this is deprecated and is only set if the min supported cluster version is >= VersionRPCNetworkStats. | [reserved](#support-status) |
| activity | [NodeStatus.ActivityEntry](#cockroach.server.status.statuspb.NodeStatus.ActivityEntry) | repeated | activity is a map of nodeIDs to network statistics from this node to other nodes. | [reserved](#support-status) |
| total_system_memory | [int64](#int64) | | total_system_memory is the total RAM available to the system (or, if detected, the memory available to the cgroup this process is in) in bytes. | [alpha](#support-status) |
| num_cpus | [int32](#int32) | | num_cpus is the number of logical CPUs as reported by the operating system on the host where the `cockroach` process is running. Note that this does not report the number of CPUs actually used by `cockroach`; this parameter is controlled separately. | [alpha](#support-status) |




<a name="cockroach.server.status.statuspb.NodeStatus.MetricsEntry"></a>
#### NodeStatus.MetricsEntry






| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [string](#string) | | | |
| value | [double](#double) | | | |




<a name="cockroach.server.status.statuspb.StoreStatus"></a>
#### StoreStatus

StoreStatus records the most recent values of metrics for a store.

Support status: [reserved](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| desc | [cockroach.roachpb.StoreDescriptor](#cockroach.roachpb.StoreDescriptor) | | desc is the store descriptor. | [reserved](#support-status) |
| metrics | [StoreStatus.MetricsEntry](#cockroach.server.status.statuspb.StoreStatus.MetricsEntry) | repeated | metrics contains the last sampled values for the node metrics. | [reserved](#support-status) |




<a name="cockroach.server.status.statuspb.StoreStatus.MetricsEntry"></a>
#### StoreStatus.MetricsEntry






| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [string](#string) | | | |
| value | [double](#double) | | | |




<a name="cockroach.server.status.statuspb.NodeStatus.LatenciesEntry"></a>
#### NodeStatus.LatenciesEntry






| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [int32](#int32) | | | |
| value | [int64](#int64) | | | |




<a name="cockroach.server.status.statuspb.NodeStatus.ActivityEntry"></a>
#### NodeStatus.ActivityEntry






| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [int32](#int32) | | | |
| value | [NodeStatus.NetworkActivity](#cockroach.server.status.statuspb.NodeStatus.NetworkActivity) | | | |




<a name="cockroach.server.status.statuspb.NodeStatus.NetworkActivity"></a>
#### NodeStatus.NetworkActivity



Support status: [reserved](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| incoming | [int64](#int64) | | in bytes | [reserved](#support-status) |
| outgoing | [int64](#int64) | | in bytes | [reserved](#support-status) |
| latency | [int64](#int64) | | in nanoseconds | [reserved](#support-status) |




<a name="cockroach.server.serverpb.NodesResponse.LivenessByNodeIdEntry"></a>
#### NodesResponse.LivenessByNodeIdEntry






| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| key | [int32](#int32) | | | |
| value | [cockroach.kv.kvserver.liveness.livenesspb.NodeLivenessStatus](#cockroach.kv.kvserver.liveness.livenesspb.NodeLivenessStatus) | | | |


12 changes: 12 additions & 0 deletions docs/generated/http/nodes-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


<a name="cockroach.server.serverpb.NodesRequest"></a>
#### NodesRequest

NodesRequest requests a copy of the node information as known to gossip
and the KV layer.

Support status: [alpha](#support-status)



16 changes: 16 additions & 0 deletions docs/generated/http/nodes-response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


<a name="cockroach.server.serverpb.NodesResponse"></a>
#### NodesResponse

NodesResponse describe the nodes in the cluster.

Support status: [alpha](#support-status)


| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| nodes | [cockroach.server.status.statuspb.NodeStatus](#cockroach.server.status.statuspb.NodeStatus) | repeated | nodes carries the status payloads for all nodes in the cluster. | [alpha](#support-status) |
| liveness_by_node_id | [NodesResponse.LivenessByNodeIdEntry](#cockroach.server.serverpb.NodesResponse.LivenessByNodeIdEntry) | repeated | liveness_by_node_id maps each node ID to a liveness status. | [reserved](#support-status) |


Loading

0 comments on commit 91a0898

Please sign in to comment.