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

Add support for providing a dir to include_conf #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hogarthj
Copy link

With this commit a directory can be provided to include_conf (such as /etc/rsnapshot.d) and then each file inside (skipping files ending with .in to make the test situation easier) will be parsed into the config.

This then allows a base configuration and for whatever method is desired to drop files into this directory to add backup lines (as I imagine the common use case will be) to provide drop in configuration of targets.

This also adds testing for include_conf to ensure it works for no include_conf, with include_conf pointing to a file and include_conf pointing to a directory.

@guestisp
Copy link

Please include only files ending with ".conf" and not all files

@hogarthj
Copy link
Author

That's a good call and is far less messier than skipping files ending in .in ;)

There's testing to ensure that the limited inclusion works as well.

Copy link
Contributor

@bebehei bebehei left a comment

Choose a reason for hiding this comment

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

  • Great idea. 100 of 100 points.
  • Albeit I don't like adding new options to the rsnapshot.conf-file, this may be better to use as an extra option like include_dir or include_confdir
  • no documentation at all... ugh.
    • For the current PR code, this could be painful for others, using the include_conf-option already.
    • If you change the code, to use a new config-option, please document the config-option.

Copy link
Contributor

@bebehei bebehei left a comment

Choose a reason for hiding this comment

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

No documentation

@bebehei
Copy link
Contributor

bebehei commented Sep 21, 2016

I'm testing GH code review features currently. This is my first PR using this, sorry for the inconvenience with it.

@hogarthj
Copy link
Author

Sorry about the lack of changes to docs ... I'll get that sorted with an update

I did have some thought about just extending include_conf though to handle directories ...

It's a "lightest touch" with no additional options being added.

users/admins who want to include don't need to special case including a directory versus including a conf snippet ... just use include_conf and let rsnapshot act appropriately.

It's a fairly trivial change to add the include_conf_dir option instead ... but I just wanted to present my line of thinking first.

Do you still want include_conf_dir as a separate option to include_conf ?

And no problem on using this for testing the review features :)

Copy link
Contributor

@bebehei bebehei left a comment

Choose a reason for hiding this comment

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

  • Great idea. 100 of 100 points.
  • Albeit I don't like adding new options to the rsnapshot.conf-file, this may be better to use as an extra option like include_dir or include_confdir
  • no documentation at all... ugh.
    • For the current PR code, this could be painful for others, using the include_conf-option already.
    • If you change the code, to use a new config-option, please document the config-option.
  • Also hardcoding *.conf may not be the best. My personal favorite is, to pass a 2nd parameter to the option. This parameter will be a regex (or glob), which will be the regex for included files.
    A regular use of this option would be: include_conf_dir /etc/rsnapshot.conf.d/ *.conf

@bebehei
Copy link
Contributor

bebehei commented Sep 21, 2016

Sorry, I did not get your recent answer before writing the my 'review'.

It's a "lightest touch" with no additional options being added.

👍

Do you still want include_conf_dir as a separate option to include_conf ?

I don't know why, but for some reasons, yes.

users/admins who want to include don't need to special case including a directory versus including a conf snippet ... just use include_conf and let rsnapshot act appropriately.

Most ppl probably expect, that include_conf implicts reading files only.

@hogarthj
Copy link
Author

That's fine - updating now ... I'm going to do a quick turnaround on the trivial addition of include_conf_dir which only looks for *.conf files ... and then there will be the final addition with the regex pattern after I'm a little happier and have done some testing around that

@hogarthj
Copy link
Author

@bebehei just in case the review stuff is confusing matters (since it has it listed as changes requested)

The changes have been made - does this look good to you now or would you like any further refining?

@hogarthj
Copy link
Author

hogarthj commented Oct 6, 2016

@bebehei As a heads up I've filed a ticket with FESCO to take over this package in Fedora, seeing as it's well out of date there and the maintainer didn't respond to an update bug.

I'd really like to get this change in, if it's now acceptable to you, before pushing the next updates there next week :)

@sgpinkus
Copy link
Member

sgpinkus commented Oct 7, 2016

@bebehei, @hogarthj Id like to review too please. Will do ASAP today.

rsnapshot-program.pl Outdated Show resolved Hide resolved
rsnapshot-program.pl Outdated Show resolved Hide resolved
@@ -6716,6 +6739,28 @@ =head1 CONFIGURATION

=back

B<include_conf_dir> Include any files in this directory at this point, defaults ending in .conf
Copy link
Member

Choose a reason for hiding this comment

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

B<include_conf_dir [conf-file-pattern=*\.conf]> would be better?

@@ -6716,6 +6739,28 @@ =head1 CONFIGURATION

=back

B<include_conf_dir> Include any files in this directory at this point, defaults ending in .conf
Copy link
Member

Choose a reason for hiding this comment

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

Include any files in this directory at this point, defaults ending in .conf

Not very clear. It's not including "any files". Suggest replace with:

Include any files in this directory at this point. By default only files ending in .conf are included.

use SysWrap;

#
# Write here in brief, what you want to check!
Copy link
Member

Choose a reason for hiding this comment

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

Um what? Your supposed to replace that with your own doc describing your test...

Copy link
Member

Choose a reason for hiding this comment

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

And delete the rest of the instructional comments..

use SysWrap;

#
# Write here in brief, what you want to check!
Copy link
Member

Choose a reason for hiding this comment

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

Dido.


=over 4

This is also recursive configuration so it's important to be careful about what snippets
Copy link
Member

Choose a reason for hiding this comment

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

Why is it "snippets" now? They're just included configuration files. Also suggest change to "... so its important included files don't cause an infinite loop".

@sgpinkus
Copy link
Member

sgpinkus commented Oct 7, 2016

Sorry for the noisy commenting - I thought I was doing a review but I was just commenting... LOL.

Also need to squash your commits, down to one or two at most.

Also note, rsnapshot will blow up on unrecognized options. Thus any new option is essentially not BWC. Pretty sure new options have been added since that config_version check was implemented though. Not sure what the policy is for bumping the config_version version...

@hogarthj
Copy link
Author

Thanks for the comments/review (although I only just saw them, oddly I didn't get emailed) ... will make the amendments and squash the commits down in the next few days

@hogarthj
Copy link
Author

Apologies for this taking a while to come back to but life got in the way a bit ...

I've made the changes you suggested, though i'm not sure what CS issue you were referring to before as the code was using tabs for spacing?

As a heads up on an unrelated note Fedora now has 1.4.2 and we'll be pushing the release to EPEL soon.

@hogarthj
Copy link
Author

hogarthj commented Dec 6, 2016

@bebehei @sam-at-github any further changes requested?

@sgpinkus
Copy link
Member

sgpinkus commented Dec 8, 2016

@hogarthj I just pushed the CS fixes I was talking about - not sure why you couldn't see what I was talking about. One more thing: you tests are setup wrong which is why you had to add all those specific pattern to the .gitignore. I reverted the .gitignore. Please observe how other tests are setup and follow that.

@hogarthj
Copy link
Author

hogarthj commented Dec 8, 2016

@sam-at-github whitespace blindness? or blame fatigue caused by my daughter? ;)

Thanks for that - no idea how my eyes glossed over it.

I tried to follow another test that was similar, which was what resulted in that. I'll take another look and clear it up to avoid the noise in gitignoe.

@simbalion
Copy link

Any chance this could get merged? It would be very useful for automating large operations.

$conf_pat = '.*\.conf$';
}
opendir(CONF_DIR, $value) or die $!;
while (my $conf_file = readdir(CONF_DIR)) {
Copy link
Member

Choose a reason for hiding this comment

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

I believe that this will go all weird if any of the files in the directory themselves include an include_conf_dir, as when it recurses it will re-use the CONF_DIR handle. Please either test this to prove it doesn't happen, or read the entire directory into an array and then close it before processing the list of files, or use a lexically scoped handle.

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

Successfully merging this pull request may close these issues.

None yet

6 participants