Skip to content
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

ncm-dpmlfc: major rewrite to support DAV configuration #86

Merged
merged 54 commits into from
Jan 11, 2016

Conversation

jouvin
Copy link
Contributor

@jouvin jouvin commented Dec 23, 2015

This PR is a major rewrite of ncm-dpmlfc to support configuring DPM WebDav protocol with ncm-dpmlfc. To do this, the ncm-xrootd rule-based editor has been ported back to DPM to replace the original one. This rule-based editor has been slightly extended but should remain compatible with the ncm-xrootd one. The intent is to move it as a new CAF module (it probably represent 1/3 of the configuration module code currently).

Another improvement in ncm-dpmlfc is in the schema: rather than specifying the protocol options for each node (whith usually the same options for all nodes), it is now possible to define the protocol options globally that will act as a default for each nodes where those options are not specified.

In addition to this feature extension, there was an extensive rewrite of this configuration module to simplify the code. The old one was based on the assumption that both DPM and LFC could be configured on the same machine, something that has never been actually possible as both product have a (different) daemon listening the same port. This was leading to a very complicated processing of the configuration that has been streamlined. A few 100s of lines have been removed!

As part of this rewrite, unit tests have been added both for some of the rule-based editor features and for the whole Configure method with basically all the config files managed by the config module checked. This allowed to uncover quite a number of flaws in the original code and is a pretty good coverage of the whole code. The new version is test friendly: the few LC::Check calls still needed have been protected by testing $CAF::Object::NoAction. When tests are run in verbose mode, the output should produce noERROR` message in addition to passing the tests.

This version has been deployed successfully at LAL yesterday and is almost ready for merging. The two remaining minor things to do are:

  • Validate pan schema in unit tests
  • Update the pod file for the DAV part and the new global options for protocols.

Having it part of 15.12 would be great! Thus the milestone. But I would understand that this is too late...

- simplify code
- update the rule-based editor by the one in ncm-xrootd
- Never add quattor comment to the pattern to ensure it works even if the line
  was not added by Quattor
- Do not process rule if the keyword was negated
- Improve logging
- Fix retrieval of global options
- Ensure that `host` attribute is defined in role options
- Also adapt configure.t to new configureNode() interface
…provements/fixes

- Options for a protocol can be defined globally rather than for each host
- Config lines can be commented out on a per line/rule basis if the option is undef
- DPM DB config file
- Certificate and private key
… fixes\

- Fix retrieval of global options (typo)'
- Update unit tests to cover each DAV rule
@jouvin jouvin added this to the 15.12 milestone Dec 23, 2015
if ( $cond_attribute ) {
# Due to Perl autovivification, testing directly exists($config_options->{$cond_option_set}->{$cond_attribute}) will spring
# $config_options->{$cond_option_set} into existence if it doesn't exist.
my $cond_true = exists($config_options->{$cond_option_set}) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first exists is not needed

@jouvin
Copy link
Contributor Author

jouvin commented Dec 30, 2015

@stdweird what about perl-enum not found during executiong of unit tests? Is it enough to list it as a dependency in the pom file?

@stdweird
Copy link
Member

test this please

@stdweird
Copy link
Member

@jouvin i added enum, tests pass again. (i forgot to do that yesterday, apologies for the delay)


=cut

sub _parse_rules {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous conversation was lost

I understand your point but the problem is how do you return a bunch of value from a Perl function (I know how to do it in Python!).

i would convert the curent variables in a hashref, and return the hashref

e.g.

sub _parse_one_rule
{
    ...
    my $res = {};
    $res->{value_fmt} = $value_fmt;
    ...
    return $res;
}

(i'm not sure i understand your question though)

You basically need to return if the rule has to be applied or not and the parameter used to edit the line after the rule is parsed. That means one boolean and one hash. Do you consider that passing the hash as an argument and having it modified by the function is a good practice?

i am talking about a rule parser, i.e. something that converts

[condition->]attribute:option_set[,option_set,...];line_fmt

in

my $rule = {
    condition => x,
    attrinute => y,
    option_set => [option1, ...],
    line_fmt =>,
}

in particular, this method should retrun undef on failure and log error in case the rule is invalid, so it can be used e.g. for unittestting the rules. in particular, all rules should be valid/parsable before a single one is applied.
right now, you apply the rules one by one, and in case there is an issue, you continue, instead of doing a $fh->cancel and return undef/stop.

…or->close() defines a return value

- Ensure that set_caf_file_close_diff(1) is executed
@jouvin jouvin force-pushed the dpmlfc branch 4 times, most recently from afa17a5 to f1777c1 Compare January 1, 2016 17:00
@jouvin
Copy link
Contributor Author

jouvin commented Jan 1, 2016

With the last commit, the suggestion to have a distinct method for parsing rules has been implemented. Updated in both ncm-dpmlfc and ncm-xrootd. 2 improvements are left for a later version:

  • cancel file modification if an error occurs applying of the rules. I agree that this should be the default behaviour but I'd like to implement the option to just ignore errors (apply as many mods as possible) to keep the current behaviour possible.
  • Preserve initial whitespace when modifying a line. This should be possible with the customized replace() used and the required feature may be provided by CAF::FileEditor in the future (Add a rule-based file editor to CAF CAF#123).

As for me, this PR is ready for merging.

@jouvin
Copy link
Contributor Author

jouvin commented Jan 1, 2016

BTW, deployed successfully at LAL.

@jrha jrha modified the milestones: 16.2, 15.12 Jan 5, 2016
@jouvin
Copy link
Contributor Author

jouvin commented Jan 5, 2016

@jrha I'd really like to see this one going into 15.12, please... It has been under a very detailed review by @stdweird and is in prod at LAL. It will bring only advantages on the previous version!

@jouvin
Copy link
Contributor Author

jouvin commented Jan 8, 2016

A bug was just uncovered at LAL in shift.conf management. I'm fixing it asap. Unfortunately this file has a rule with a specific feature and was not enough unit tested, conversely to other files... Another proof that we should never minimize the effort on unit tests!

- Also removed LINE_VALUE_HOST_LIST from rule-based editor (not used anywhere,
can be done with LINE_VALUE_ARRAY)
- Unit tests improved
- Rule-based editor updated in ncm-xrootd too
@jouvin
Copy link
Contributor Author

jouvin commented Jan 8, 2016

Pb fixed, new version deployed successfully at LAL, missing coverage in unit tests fixed.

@jrha is there any change to have it included in 15.12, I saw that RC2 is out already, I know this is late but there are some important fixes for people using Quattor to manage DPM...

@jrha jrha modified the milestones: 15.12, 16.2 Jan 11, 2016
jrha added a commit that referenced this pull request Jan 11, 2016
ncm-dpmlfc: major rewrite to support DAV configuration
@jrha jrha merged commit 117a3a2 into quattor:master Jan 11, 2016
@jrha
Copy link
Member

jrha commented Jan 11, 2016

I spend a while thinking about this, but in the end decided that given it only touches one grid component which is known to have issues, it was better off merged.

@jouvin
Copy link
Contributor Author

jouvin commented Jan 11, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants