add cluster health

This commit is contained in:
Quentin 2023-11-28 14:32:11 +01:00
parent f7b4e20e42
commit 2d012ad1b9
Signed by: quentin
GPG Key ID: E9602264D639FF68
8 changed files with 375 additions and 10 deletions

View File

@ -16,6 +16,7 @@ docs/ClusterLayout.md
docs/CreateBucketRequest.md
docs/CreateBucketRequestLocalAlias.md
docs/CreateBucketRequestLocalAliasAllow.md
docs/GetHealth200Response.md
docs/GetNodes200Response.md
docs/ImportKeyRequest.md
docs/KeyApi.md
@ -62,6 +63,7 @@ src/model/ClusterLayout.js
src/model/CreateBucketRequest.js
src/model/CreateBucketRequestLocalAlias.js
src/model/CreateBucketRequestLocalAliasAllow.js
src/model/GetHealth200Response.js
src/model/GetNodes200Response.js
src/model/ImportKeyRequest.js
src/model/KeyInfo.js
@ -83,3 +85,4 @@ src/model/UpdateBucketRequestWebsiteAccess.js
src/model/UpdateKeyRequest.js
src/model/UpdateKeyRequestAllow.js
src/model/UpdateKeyRequestDeny.js
test/model/GetHealth200Response.spec.js

View File

@ -146,8 +146,9 @@ Class | Method | HTTP request | Description
*garage.LayoutApi* | [**applyLayout**](docs/LayoutApi.md#applyLayout) | **POST** /layout/apply | Apply staged layout
*garage.LayoutApi* | [**getLayout**](docs/LayoutApi.md#getLayout) | **GET** /layout | Details on the current and staged layout
*garage.LayoutApi* | [**revertLayout**](docs/LayoutApi.md#revertLayout) | **POST** /layout/revert | Clear staged layout
*garage.NodesApi* | [**addNode**](docs/NodesApi.md#addNode) | **POST** /connect | Connect target node to other Garage nodes
*garage.NodesApi* | [**getNodes**](docs/NodesApi.md#getNodes) | **GET** /status | Status of this node and other nodes in the cluster
*garage.NodesApi* | [**addNode**](docs/NodesApi.md#addNode) | **POST** /connect | Connect a new node
*garage.NodesApi* | [**getHealth**](docs/NodesApi.md#getHealth) | **GET** /health | Cluster health report
*garage.NodesApi* | [**getNodes**](docs/NodesApi.md#getNodes) | **GET** /status | Describe cluster
## Documentation for Models
@ -165,6 +166,7 @@ Class | Method | HTTP request | Description
- [garage.CreateBucketRequest](docs/CreateBucketRequest.md)
- [garage.CreateBucketRequestLocalAlias](docs/CreateBucketRequestLocalAlias.md)
- [garage.CreateBucketRequestLocalAliasAllow](docs/CreateBucketRequestLocalAliasAllow.md)
- [garage.GetHealth200Response](docs/GetHealth200Response.md)
- [garage.GetNodes200Response](docs/GetNodes200Response.md)
- [garage.ImportKeyRequest](docs/ImportKeyRequest.md)
- [garage.KeyInfo](docs/KeyInfo.md)

View File

@ -0,0 +1,16 @@
# garage.GetHealth200Response
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**status** | **String** | |
**knownNodes** | **Number** | |
**connectedNodes** | **Number** | |
**storageNodes** | **Number** | |
**storageNodesOk** | **Number** | |
**partitions** | **Number** | |
**partitionsQuorum** | **Number** | |
**partitionsAllOk** | **Number** | |

View File

@ -4,8 +4,9 @@ All URIs are relative to *http://localhost:3903/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**addNode**](NodesApi.md#addNode) | **POST** /connect | Connect target node to other Garage nodes
[**getNodes**](NodesApi.md#getNodes) | **GET** /status | Status of this node and other nodes in the cluster
[**addNode**](NodesApi.md#addNode) | **POST** /connect | Connect a new node
[**getHealth**](NodesApi.md#getHealth) | **GET** /health | Cluster health report
[**getNodes**](NodesApi.md#getNodes) | **GET** /status | Describe cluster
@ -13,7 +14,7 @@ Method | HTTP request | Description
> [AddNode200ResponseInner] addNode(requestBody)
Connect target node to other Garage nodes
Connect a new node
Instructs this Garage node to connect to other Garage nodes at specified `<node_id>@<net_address>`. `node_id` is generated automatically on node start.
@ -57,11 +58,55 @@ Name | Type | Description | Notes
- **Accept**: application/json
## getHealth
> GetHealth200Response getHealth()
Cluster health report
Returns the global status of the cluster, the number of connected nodes (over the number of known ones), the number of healthy storage nodes (over the declared ones), and the number of healthy partitions (over the total).
### Example
```javascript
import garage from 'garage_administration_api_v0garage_v0_9_0';
let defaultClient = garage.ApiClient.instance;
// Configure Bearer access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
let apiInstance = new garage.NodesApi();
apiInstance.getHealth().then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**GetHealth200Response**](GetHealth200Response.md)
### Authorization
[bearerAuth](../README.md#bearerAuth)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
## getNodes
> GetNodes200Response getNodes()
Status of this node and other nodes in the cluster
Describe cluster
Returns the cluster's current status, including: - ID of the node being queried and its version of the Garage daemon - Live nodes - Currently configured cluster layout - Staged changes to the cluster layout *Capacity is given in bytes*

View File

@ -14,6 +14,7 @@
import ApiClient from "../ApiClient";
import AddNode200ResponseInner from '../model/AddNode200ResponseInner';
import GetHealth200Response from '../model/GetHealth200Response';
import GetNodes200Response from '../model/GetNodes200Response';
/**
@ -37,7 +38,7 @@ export default class NodesApi {
/**
* Connect target node to other Garage nodes
* Connect a new node
* Instructs this Garage node to connect to other Garage nodes at specified `<node_id>@<net_address>`. `node_id` is generated automatically on node start.
* @param {Array.<String>} requestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<module:model/AddNode200ResponseInner>} and HTTP response
@ -70,7 +71,7 @@ export default class NodesApi {
}
/**
* Connect target node to other Garage nodes
* Connect a new node
* Instructs this Garage node to connect to other Garage nodes at specified `<node_id>@<net_address>`. `node_id` is generated automatically on node start.
* @param {Array.<String>} requestBody
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<module:model/AddNode200ResponseInner>}
@ -84,7 +85,48 @@ export default class NodesApi {
/**
* Status of this node and other nodes in the cluster
* Cluster health report
* Returns the global status of the cluster, the number of connected nodes (over the number of known ones), the number of healthy storage nodes (over the declared ones), and the number of healthy partitions (over the total).
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetHealth200Response} and HTTP response
*/
getHealthWithHttpInfo() {
let postBody = null;
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['bearerAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = GetHealth200Response;
return this.apiClient.callApi(
'/health', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null
);
}
/**
* Cluster health report
* Returns the global status of the cluster, the number of connected nodes (over the number of known ones), the number of healthy storage nodes (over the declared ones), and the number of healthy partitions (over the total).
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetHealth200Response}
*/
getHealth() {
return this.getHealthWithHttpInfo()
.then(function(response_and_data) {
return response_and_data.data;
});
}
/**
* Describe cluster
* Returns the cluster's current status, including: - ID of the node being queried and its version of the Garage daemon - Live nodes - Currently configured cluster layout - Staged changes to the cluster layout *Capacity is given in bytes*
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GetNodes200Response} and HTTP response
*/
@ -112,7 +154,7 @@ export default class NodesApi {
}
/**
* Status of this node and other nodes in the cluster
* Describe cluster
* Returns the cluster's current status, including: - ID of the node being queried and its version of the Garage daemon - Live nodes - Currently configured cluster layout - Staged changes to the cluster layout *Capacity is given in bytes*
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GetNodes200Response}
*/

View File

@ -26,6 +26,7 @@ import ClusterLayout from './model/ClusterLayout';
import CreateBucketRequest from './model/CreateBucketRequest';
import CreateBucketRequestLocalAlias from './model/CreateBucketRequestLocalAlias';
import CreateBucketRequestLocalAliasAllow from './model/CreateBucketRequestLocalAliasAllow';
import GetHealth200Response from './model/GetHealth200Response';
import GetNodes200Response from './model/GetNodes200Response';
import ImportKeyRequest from './model/ImportKeyRequest';
import KeyInfo from './model/KeyInfo';
@ -169,6 +170,12 @@ export {
*/
CreateBucketRequestLocalAliasAllow,
/**
* The GetHealth200Response model constructor.
* @property {module:model/GetHealth200Response}
*/
GetHealth200Response,
/**
* The GetNodes200Response model constructor.
* @property {module:model/GetNodes200Response}

View File

@ -0,0 +1,143 @@
/**
* Garage Administration API v0+garage-v0.9.0
* Administrate your Garage cluster programatically, including status, layout, keys, buckets, and maintainance tasks. *Disclaimer: The API is not stable yet, hence its v0 tag. The API can change at any time, and changes can include breaking backward compatibility. Read the changelog and upgrade your scripts before upgrading. Additionnaly, this specification is very early stage and can contain bugs, especially on error return codes/types that are not tested yet. Do not expect a well finished and polished product!*
*
* The version of the OpenAPI document: v0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
import ApiClient from '../ApiClient';
/**
* The GetHealth200Response model module.
* @module model/GetHealth200Response
* @version v0.9.0
*/
class GetHealth200Response {
/**
* Constructs a new <code>GetHealth200Response</code>.
* @alias module:model/GetHealth200Response
* @param status {String}
* @param knownNodes {Number}
* @param connectedNodes {Number}
* @param storageNodes {Number}
* @param storageNodesOk {Number}
* @param partitions {Number}
* @param partitionsQuorum {Number}
* @param partitionsAllOk {Number}
*/
constructor(status, knownNodes, connectedNodes, storageNodes, storageNodesOk, partitions, partitionsQuorum, partitionsAllOk) {
GetHealth200Response.initialize(this, status, knownNodes, connectedNodes, storageNodes, storageNodesOk, partitions, partitionsQuorum, partitionsAllOk);
}
/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj, status, knownNodes, connectedNodes, storageNodes, storageNodesOk, partitions, partitionsQuorum, partitionsAllOk) {
obj['status'] = status;
obj['knownNodes'] = knownNodes;
obj['connectedNodes'] = connectedNodes;
obj['storageNodes'] = storageNodes;
obj['storageNodesOk'] = storageNodesOk;
obj['partitions'] = partitions;
obj['partitionsQuorum'] = partitionsQuorum;
obj['partitionsAllOk'] = partitionsAllOk;
}
/**
* Constructs a <code>GetHealth200Response</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/GetHealth200Response} obj Optional instance to populate.
* @return {module:model/GetHealth200Response} The populated <code>GetHealth200Response</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new GetHealth200Response();
if (data.hasOwnProperty('status')) {
obj['status'] = ApiClient.convertToType(data['status'], 'String');
}
if (data.hasOwnProperty('knownNodes')) {
obj['knownNodes'] = ApiClient.convertToType(data['knownNodes'], 'Number');
}
if (data.hasOwnProperty('connectedNodes')) {
obj['connectedNodes'] = ApiClient.convertToType(data['connectedNodes'], 'Number');
}
if (data.hasOwnProperty('storageNodes')) {
obj['storageNodes'] = ApiClient.convertToType(data['storageNodes'], 'Number');
}
if (data.hasOwnProperty('storageNodesOk')) {
obj['storageNodesOk'] = ApiClient.convertToType(data['storageNodesOk'], 'Number');
}
if (data.hasOwnProperty('partitions')) {
obj['partitions'] = ApiClient.convertToType(data['partitions'], 'Number');
}
if (data.hasOwnProperty('partitionsQuorum')) {
obj['partitionsQuorum'] = ApiClient.convertToType(data['partitionsQuorum'], 'Number');
}
if (data.hasOwnProperty('partitionsAllOk')) {
obj['partitionsAllOk'] = ApiClient.convertToType(data['partitionsAllOk'], 'Number');
}
}
return obj;
}
}
/**
* @member {String} status
*/
GetHealth200Response.prototype['status'] = undefined;
/**
* @member {Number} knownNodes
*/
GetHealth200Response.prototype['knownNodes'] = undefined;
/**
* @member {Number} connectedNodes
*/
GetHealth200Response.prototype['connectedNodes'] = undefined;
/**
* @member {Number} storageNodes
*/
GetHealth200Response.prototype['storageNodes'] = undefined;
/**
* @member {Number} storageNodesOk
*/
GetHealth200Response.prototype['storageNodesOk'] = undefined;
/**
* @member {Number} partitions
*/
GetHealth200Response.prototype['partitions'] = undefined;
/**
* @member {Number} partitionsQuorum
*/
GetHealth200Response.prototype['partitionsQuorum'] = undefined;
/**
* @member {Number} partitionsAllOk
*/
GetHealth200Response.prototype['partitionsAllOk'] = undefined;
export default GetHealth200Response;

View File

@ -0,0 +1,107 @@
/**
* Garage Administration API v0+garage-v0.9.0
* Administrate your Garage cluster programatically, including status, layout, keys, buckets, and maintainance tasks. *Disclaimer: The API is not stable yet, hence its v0 tag. The API can change at any time, and changes can include breaking backward compatibility. Read the changelog and upgrade your scripts before upgrading. Additionnaly, this specification is very early stage and can contain bugs, especially on error return codes/types that are not tested yet. Do not expect a well finished and polished product!*
*
* The version of the OpenAPI document: v0.9.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', process.cwd()+'/src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require(process.cwd()+'/src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.garage);
}
}(this, function(expect, garage) {
'use strict';
var instance;
beforeEach(function() {
instance = new garage.GetHealth200Response();
});
var getProperty = function(object, getter, property) {
// Use getter method if present; otherwise, get the property directly.
if (typeof object[getter] === 'function')
return object[getter]();
else
return object[property];
}
var setProperty = function(object, setter, property, value) {
// Use setter method if present; otherwise, set the property directly.
if (typeof object[setter] === 'function')
object[setter](value);
else
object[property] = value;
}
describe('GetHealth200Response', function() {
it('should create an instance of GetHealth200Response', function() {
// uncomment below and update the code to test GetHealth200Response
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be.a(garage.GetHealth200Response);
});
it('should have the property status (base name: "status")', function() {
// uncomment below and update the code to test the property status
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property knownNodes (base name: "knownNodes")', function() {
// uncomment below and update the code to test the property knownNodes
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property connectedNodes (base name: "connectedNodes")', function() {
// uncomment below and update the code to test the property connectedNodes
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property storageNodes (base name: "storageNodes")', function() {
// uncomment below and update the code to test the property storageNodes
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property storageNodesOk (base name: "storageNodesOk")', function() {
// uncomment below and update the code to test the property storageNodesOk
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property partitions (base name: "partitions")', function() {
// uncomment below and update the code to test the property partitions
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property partitionsQuorum (base name: "partitionsQuorum")', function() {
// uncomment below and update the code to test the property partitionsQuorum
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
it('should have the property partitionsAllOk (base name: "partitionsAllOk")', function() {
// uncomment below and update the code to test the property partitionsAllOk
//var instance = new garage.GetHealth200Response();
//expect(instance).to.be();
});
});
}));