#66 dsconf healthcheck command
Closed: Fixed Opened by firstyear.

We have the ability to "lint" or healthcheck modules in lib389. We should expand dsconf to be able to consume these and give warnings based on checks in the modules. An example already exists for backend, but we can expand to anything that derives mapped_object.


Metadata Update from @firstyear:
- Issue assigned to firstyear

Metadata Update from @firstyear:
- Custom field Review Status adjusted to review

I wonder if we can use ensure_str() directly inside get_attr_val() etc.

I thought about this, and I don't think we can. See, LDAP values are naturally bytes anyway. This is from the RFC about the protocol, that attributes are always an array of bytes, and it's up to you to know the syntax to determine it properly. (dn's on the contrary are always utf8)

So it's possible for an attr like UserCertificate on jpegPhoto to be bytes that make something up - and not a utf8 string.

AS a result, we can't just blindly apply this to the function.

An option might be to have a flag representing the return type we want:

get_attr_val(type='utf-8')

Or to have various fn wrappers with single types:

get_attr_val_utf8()
get_attr_val_int()

I'm not sure which is better tbh. I think I prefer the functions per type,

I vote for functions per type as well. I don't like flag arguments, they are violating the single responsibility principle.

Update based on changes to master.
0001-Ticket-66-expand-healthcheck-for-Directory-Server.patch

I vote for functions per type as well. I don't like flag arguments, they are violating the single responsibility principle.

I'm making this a new ticket https://pagure.io/lib389/issue/67 for addressing this aspect.

Otherwise, do the commands seem correct/valid? These are a bit harder to test, but I probably can add test cases to this .... .

It looks good to me and it seems to work fine on my local instance.

Something tiny and not very important, but maybe it would enhance readability a little bit is to break the health_check_run function to smaller ones.

I mean to make it like this (with better function names than the ones that I chose probably):

def health_check_run(inst, basedn, log, args):
    log.info("Beginning lint report, this could take a while ...")
    report = health_check_many() + health_check_single()
    log.info("Healthcheck complete!")
    for item in report:
        _format_check_output(log, item)

And yes it would be nice to have some test cases for this as well.

0001-Ticket-66-expand-healthcheck-for-Directory-Server.patch

Added tests, and moved errors to a dedicated location.

Looks good to me. @ilias95 if you are good, feel free to set ack.

Metadata Update from @ilias95:
- Custom field Review Status adjusted to ack (was: review)

commit dce79c5621e4cb344fa4932c45ccd6c7e34817cc
To ssh://git@pagure.io/lib389.git
ede3dc0..65499d4 master -> master

Metadata Update from @firstyear:
- Issue status updated to: Closed (was: Open)

Metadata Update from @firstyear:
- Issue close_status updated to: Fixed

Metadata