Skip to content

Commit

Permalink
Merge pull request #486 from openvstorage/develop
Browse files Browse the repository at this point in the history
Promote
  • Loading branch information
JeffreyDevloo authored Aug 28, 2018
2 parents 2896021 + 75554fe commit 27bb602
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 95 deletions.
98 changes: 94 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,106 @@ print result.counter
print result.result_dict
```

## 4. Important to know!
If you wish to avoid manually passing the results instance, you could opt for the HealthCheckCLIRunner:
```
from ovs.extensions.healthcheck.expose_to_cli import HealthCheckCLIRunner
output = HealthCheckCLIRunner.run_method() # Same as calling ovs healthcheck
output = HealthCheckCLIRunner.run_method('ovs') # Same as calling ovs healthcheck ovs
output = HealthCheckCLIRunner.run_method('ovs', 'nginx-ports'test') # Same as calling ovs healthcheck nginx-ports-test
# Output format:
{'recap': {'EXCEPTION': 0,
'FAILED': 0,
'SKIPPED': 11,
'SUCCESS': 182,
'WARNING': 0},
'result': {'alba-backend-test': {'messages': OrderedDict([('error', []), ('exception', []), ('skip', []), ('success', [{'message': 'We found 3 backend(s)!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID t5X9va8aO6bnxifPlRjk7FxIeMFeeUEi succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID ZnIec3oF1c9zaWcmA8X9N4BN1PMZLtEq succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID kxvqKj3DH69tAmVPWwtpBwlgwGTOCYsE succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID R5P6oRaRZrVlnT6bHvW6Jr60PTNqMgBY succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID oqBbYRDrDZUr941YcjBeuDNgwa54x5B8 succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID t15miMiMTXtPAlvBOUIVUXReVKwEcGEK succeeded!', 'code': 'HC000'}, {'message': 'Alba backend mybackend02 should be available for VPool use. All asds are working fine!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID F8q0gti78jBiBtIZMOWubYgXyo5MFhJJ succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID uMeRaJSV4YFzX2KmGGRZL0lInTBvtyAS succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID iNnUDyOb4v1aIDc5kzsf6u7uV6uv50ax succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID YrgPKQlFHvEv3HKikLZ85N0lfLzZbiY2 succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID ixbskq2MUnWpioEHAkkyrLAqOxQuNx30 succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID lg0gR9pGJKY8SZauTU3QjtfhlI6g1ST6 succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID ErDkFxfe28JUMzlHQjZUmVfDO6vhtBlU succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID 70R56wudQYpJixzeQ0vj4pSS0a1KgCDJ succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID RQJkYgrICOflecO5QrD8llYEaZt2CoAT succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID oHaT2TpprxJr7WHfyXSfEAkfbaTjFVfZ succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID 80YRsH75fS9mN8S6t6A3QZ7HqEaDYeKF succeeded!', 'code': 'HC000'}, {'message': 'ASD test with DISK_ID q8iEivSKPwOfA1rJJL7ShOSkAMiO4uNS succeeded!', 'code': 'HC000'}, {'message': 'Alba backend mybackend should be available for VPool use. All asds are working fine!', 'code': 'HC000'}]), ('warning', [])]),
'state': 'SUCCESS'},
'alba-disk-safety-test': {'messages': OrderedDict([('error', []), ('exception', []), ('skip', []), ('success', [{'message': 'All data is safe on backend mybackend02 with 1 namespace(s)', 'code': 'HC000'}, {'message': 'All data is safe on backend mybackend with 1 namespace(s)', 'code': 'HC000'}]), ('warning', [])]),
'state': 'SUCCESS'},
....
```

## 4. Configuration
Certain checks accept arguments to allow tweaking. Checking which tests accept which options can be found using --help option
```
ovs healthcheck alba disk-safety-test --help
Usage: alba alba disk-safety-test [OPTIONS]
Verifies that namespaces have enough safety
Options:
-b, --backend TEXT Backend(s) to check for. Can be provided
multiple times. Ignored if --skip-backend
option is given
-s, --skip-backend TEXT Backend(s) to skip checking for. Can be
provided multiple times
-i, --include-errored-as-dead OSDs with errors as treated as dead ones
during the calculation
--help
```
These options can then be given through the CLI: `ovs healthcheck alba disk-safety-test -s mybackend -s mybackend-global`

## 4.1 Overriding defaults
The Healthcheck works with a number of default arguments for certain tests (in the example above: no backend is skipped by default)
These defaults can be fine tuned for all Healthcheck across the cluster by creating a default-map within Configuration

The key to provide the defaults under: /ovs/healthcheck/default_arguments
Configs are to be set under MODULE : TEST: PARAM NAME PYTHONIFIED
An example:
```
{
"alba": {
"disk-safety-test": {
"include_errored_as_dead": false,
"skip_backend": [],
"backend": []
}
}
```
The possible value is dependent on the type of argument to be set. When an option can be specified multiple times: the argument has to be a list. Types like text require a string, float/integer the numeric values, ...

A complete dict of all possible options and their current value can be generated:
```
from ovs.extensions.healthcheck.expose_to_cli import HealthCheckCLIRunner
HealthCheckCLIRunner.generate_configuration_options?
Type: instancemethod
String form: <bound method type.generate_configuration_options of <class 'ovs.extensions.healthcheck.expose_to_cli.HealthCheckCLIRunner'>>
File: /opt/OpenvStorage/ovs/extensions/healthcheck/expose_to_cli.py
Definition: HealthCheckCLIRunner.generate_configuration_options(cls, re_use_current_settings=False)
Docstring:
Generate a complete structure indicating where tweaking is possible together with the default values
:param re_use_current_settings: Re-use the settings currently set. Defaults to False
It will regenerate a complete structure and apply the already set values if set to True
:return: All options available to the healthcheck
:rtype: dict
```

Setting all current possible options before tweaking them:
```
from ovs.extensions.generic.configuration import Configuration
from ovs.extensions.healthcheck.expose_to_cli import HealthCheckShared, HealthCheckCLIRunner
Configuration.set(HealthCheckShared.CONTEXT_SETTINGS_KEY, HealthCheckCLIRunner.generate_configuration_options())
```

When new arguments are added: the generation can take your old settings into account by providing `True'

```
from ovs.extensions.generic.configuration import Configuration
from ovs.extensions.healthcheck.expose_to_cli import HealthCheckShared, HealthCheckCLIRunner
Configuration.set(HealthCheckShared.CONTEXT_SETTINGS_KEY, HealthCheckCLIRunner.generate_configuration_options(True))
```

## 5. Important to know!
* No files in the vPools may be named after: `ovs-healthcheck-test-{storagerouter_id}.xml`
* No volumes in the vPools may be named after: `ovs-healthcheck-test-{storagerouter_id}.raw`

## 5. Branch Info or contributions
## 6. Branch Info or contributions
* The 'master' branch is marked as the main but unstable branch
* The 'release' branches are the official releases of the HEALTH CHECK Project
* We'd love to have your contributions, read [Community Information](CONTRIBUTION.md) and [Rules of conduct](RULES.md) for notes on how to get started.

## 6. File a bug
## 7. File a bug
Open vStorage and it's automation is quality checked to the highest level.
Unfortunately we might have overlooked some tiny topics here or there.
The Open vStorage HEALTH CHECK Project maintains a [public issue tracker](https://github.com/openvstorage/openvstorage-health-check/issues)
Expand All @@ -82,6 +172,6 @@ This issue tracker is not a customer support forum but an error, flaw, failure,

If you want to submit a bug, please read the [Community Information](CONTRIBUTION.md) for notes on how to get started.

# 7. License
# 8. License
The Open vStorage HealthCheck is licensed under the [GNU AFFERO GENERAL PUBLIC LICENSE Version 3](https://www.gnu.org/licenses/agpl.html).

3 changes: 2 additions & 1 deletion ovs/extensions/healthcheck/config/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class ErrorCodes(object):
# Disk safety
'disk_safety_ok': ErrorCode('ALBA0300', 'All data for the backend is safe, no data is at risk', no_action),
'disk_safety_warn': ErrorCode('ALBA0301', 'Not all data is completely safe, certain fragments are to be repaired', 'Validate whether all OSDs are running'),
'disk_safety_error': ErrorCode('ALBA0302', 'The data is at risk or might have suffered some loss!', 'Validate whether all OSDs are running'),
'disk_safety_error_zero': ErrorCode('ALBA0302', 'The data is at risk or might have suffered some loss!', 'Validate whether all OSDs are running'),
'disk_safety_error_negative': ErrorCode('ALBA0303', 'The data has suffered some loss!', 'Validate whether all OSDs are running'),
# Services
'alba_service_running': ErrorCode('ALBA0400', 'The Alba service is up and running', no_action),
'alba_service_down': ErrorCode('ALBA0401', 'The Alba service is not running', 'Validate whether the Alba service has been started'),
Expand Down
3 changes: 2 additions & 1 deletion ovs/extensions/healthcheck/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def ensure_single_with_callback(key, callback=None, lock_type='local'):
:param lock_type: Type of lock (can be local or cluster)
"""
def wrapper(func):

@wraps(func)
def wrapped(*args, **kwargs):
if lock_type == 'local':
Expand Down Expand Up @@ -80,7 +81,7 @@ def wrapped(*args, **kwargs):
result_handler = arguments.pop(index)
break
if result_handler is None:
raise TypeError('Expected an instance of {0}'.format(type(HCResults.HCResultCollector)))
raise TypeError('Expected an instance of {0}'.format(HCResults.HCResultCollector))
kwargs['result_handler'] = result_handler
return callback_func(**kwargs)
finally:
Expand Down
Loading

0 comments on commit 27bb602

Please sign in to comment.