-
Notifications
You must be signed in to change notification settings - Fork 457
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
(MODULES-7990) Merge multiple comments into one while parsing rules #789
(MODULES-7990) Merge multiple comments into one while parsing rules #789
Conversation
d564f81
to
52a5bed
Compare
a25b523
to
e66cbc9
Compare
@mateusz-gozdek-sociomantic I am so sorry, that was meant to go on another PR. A little bit stressed at the moment. |
e66cbc9
to
b62cb7c
Compare
Pushed with acceptance test added based on https://github.com/puppetlabs/puppetlabs-firewall/pull/789/files#diff-65287c59210687fbd22cf68976ae1ad1R52 (which BTW I'm not sure why assumes comment "http" is invalid). |
@mateusz-gozdek-sociomantic Unfortunately your new test seems to have failed when run against both redhat 5 and centos 5. This is the stacktrace that was given back:
Sorry I don't have better news. |
Ugh, it seems that iptables v1.3.5 does not allow you to specify multiple comments... Any suggestions how to resolve this? |
@mateusz-gozdek-sociomantic If it is a limitation of the code and not just an error, then the only thing you can really do is note it in the documentation and put an exception into the test. Here's an examle of one such exception that is used in the module:
The above exception excludes all RedHat family OS lower than version 7, Oracle Linux OS equal to or lower than 7 and SLES OS equal to or lower than 11. |
Ok, I'll add it and run tests on CentOS 5. The code itself is OK, it's just this test, which will fail on this platform, as it is not possible to get multiple comments there. Could we maybe run this test only for iptables version higher than X? |
b62cb7c
to
ea42502
Compare
spec/acceptance/resource_cmd_spec.rb
Outdated
@@ -64,6 +64,23 @@ | |||
end | |||
end | |||
|
|||
if default['platform'] !~ %r{centos-5} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @david22swan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateusz-gozdek-sociomantic Looks good but RedHat 5 needs to be excluded as well. Also I would prefer it if you where to use the syntax that I gave you, just to maintain consistency with the rest of the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I forgot about RedHat 5. Hmm, speaking of consistency, it seems that since we don't want to disable describe
, but only one specific context
, if
should be used instead of unless
. Example: https://github.com/puppetlabs/puppetlabs-firewall/blob/master/spec/acceptance/purge_spec.rb#L128-L129
It seems for me, that using el-5
should be the right choice in this case.
BTW, feel free to push any code to this PR or suggest specific changes if this can make things faster :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateusz-gozdek-sociomantic When you excluded RedHat 5 your allowed Centos 5 back in. To speed things up I'm just gonna give you some code that I tested, should work fine:
context 'when accepts rules with multiple comments', unless: (fact('operatingsystem') == 'RedHat' && fact('operatingsystemmajrelease') <= '5') ||
(fact('operatingsystem') == 'CentOS' && fact('operatingsystemmajrelease') <= '5') do
before(:all) do
iptables_flush_all_tables
shell('iptables -A INPUT -j ACCEPT -p tcp --dport 80 -m comment --comment "http" -m comment --comment "http"')
end
it do
shell('puppet resource firewall') do |r|
r.exit_code.should be_zero
# don't check stdout, testing preexisting rules, output is normal
r.stderr.should be_empty
end
end
end
Sorry for the wait, had some other stuff to handle, also if I push to your fork then I can't merge your pr, it's why I have been avoiding doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I thought matching for el-5
will disable all follwoing platforms from testing:
spec/acceptance/nodesets/new/pe/centos-5-64mda.yml: platform: el-5-x86_64
spec/acceptance/nodesets/new/pe/oracle-5-64mda.yml: platform: el-5-x86_64
spec/acceptance/nodesets/new/pe/redhat-5-64mda.yml: platform: el-5-x86_64
spec/acceptance/nodesets/new/pe/scientific-5-64mda.yml: platform: el-5-x86_64
Anyway, that's for posting the snippet, I'll give it a try locally and then push if it works.
Sorry for the wait, had some other stuff to handle, also if I push to your fork then I can't merge your pr, it's why I have been avoiding doing it.
No worries about the timing, but out of curiosity, why couldn't you merge it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a company rule, except in certain situations, i..e. on new modules you are making or simple doc fixes, you are not allowed to merge your own PRs or any PR you have contributed to. It's to ensure that no error's are missed.
0da2908
to
46ebef1
Compare
As iptables/iptables-save accepts multiple '-m comment --comment' parameters, we should find and merge them all together to avoid generating warnings. Since puppet resource allows you to create only single comment, this should only affect rules, which are not managed by puppet.
@mateusz-gozdek-sociomantic Have kicked your changes into the adhoc pipeline but their packed right now so are unlikely to finish today, so have a good weekend and if all goes well I should have your changes merged in on monday. |
Great news @david22swan, thanks a lot for all help! I'm also aligning #790 to this PR, as I didn't know few things and that one is slightly larger. |
@mateusz-gozdek-sociomantic Adhoc finished earlier than I thought so happy to merge :) |
Thanks for the pr, it's always nice to have a contributor get back to you so promptly. Will take a look at you other pr on monday. |
I can tell the same for maintainer ;) Thanks for merging. |
As iptables/iptables-save accepts multiple '-m comment --comment' parameters,
we should find and merge them all together to avoid generating warnings.
Since puppet resource allows you to create only single comment, this should only
affect rules, which are not managed by puppet.