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

Split resolv.conf in lines #618

Merged
merged 2 commits into from
Feb 27, 2018
Merged

Split resolv.conf in lines #618

merged 2 commits into from
Feb 27, 2018

Conversation

maneta
Copy link

@maneta maneta commented Feb 21, 2018

So the code does not brake like with comented #nameserver lines

@maneta maneta force-pushed the fix-resolv-conf-parser branch 9 times, most recently from 3f2de36 to e016852 Compare February 22, 2018 00:20
insert(nameservers, nameserver.new(server))
end

for line in gmatch(resolv_conf, '(.*)\n]') do
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this could be better as:

for _,line in ipairs(re.split(resolv_conf, [[\n+$]])) do

Copy link
Contributor

Choose a reason for hiding this comment

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

And actually I think it would be nice to extract parsing of the file into own function so it can be unit tested. I can do that if you want.

Also looks like there is similar bug on line 116 in this file. search would also be extracted from a comment line.

Copy link
Author

Choose a reason for hiding this comment

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

@mikz go ahead this was just me playing around with lua regex. But lua was winning me :)

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want I'm happy to provide guidance and let you do it ;)

Copy link
Author

Choose a reason for hiding this comment

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

yay! Thanks @mikz I will do it then

@maneta maneta force-pushed the fix-resolv-conf-parser branch 8 times, most recently from 5b4452d to 999317e Compare February 27, 2018 09:35
@@ -34,6 +34,15 @@ GET /t
nameservers: 3 127.0.1.15353 1.2.3.453 4.5.6.753
--- user_files
>>> resolv.conf
# nameserver updated in comentary
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good. It's testing more things than before, so I think it's worth expanding the description of the test (line 16).

Copy link
Author

Choose a reason for hiding this comment

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

done in d49b712

@@ -163,6 +163,14 @@ describe('resty.resolver', function()
before_each(function()
tmpname = io.tmpfile()

tmpname:write('# nameserver updated in comentary\n')
Copy link
Contributor

@davidor davidor Feb 27, 2018

Choose a reason for hiding this comment

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

How about calling write just once? I think it looks better:

      tmpname:write(
        [[# nameserver updated  in comentary\n
          #nameserver updated  in comentary\n
          #comentary nameserver\n
          ..............]])

(I think the '\n' need to be there, but better test it to be sure)

Copy link
Author

Choose a reason for hiding this comment

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

done in d49b712

@davidor
Copy link
Contributor

davidor commented Feb 27, 2018

Travis tests are failing because https://olivinelabs.com/busted/ is down, so don't worry about those.

-- TODO: implement port matching based on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549190
if server ~= resolver then
if server and server ~= resolver then
Copy link
Contributor

@davidor davidor Feb 27, 2018

Choose a reason for hiding this comment

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

I think we don't have tests for the case where server == resolver.

Copy link
Author

Choose a reason for hiding this comment

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

Actual this test case fails.

We have agreed (me and @davidor) that we should address those problems in another PR.

The issue which treat this case is #630

@maneta maneta changed the title WIP - Splits resolv.conf in lines Split resolv.conf in lines Feb 27, 2018
@maneta maneta mentioned this pull request Feb 27, 2018
2 tasks
Copy link
Contributor

@davidor davidor left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Can you please add a changelog entry @maneta ?

Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

👍 thank you @maneta

You'll need to add a CHANGELOG entry and then it is good to merge.

@davidor
Copy link
Contributor

davidor commented Feb 27, 2018

@maneta the changelog entry is not under the correct version. It should be under unreleased.
Regarding the subsection, I think this should be under fixed instead of changed because it fixes a bug.

@maneta maneta force-pushed the fix-resolv-conf-parser branch 2 times, most recently from 9e491a7 to 97470e0 Compare February 27, 2018 20:44
@maneta
Copy link
Author

maneta commented Feb 27, 2018

Got it @davidor now it should be good to go :)

@mikz
Copy link
Contributor

mikz commented Feb 27, 2018

@maneta there are conflicts with master. You'll need to rebase/merge master branch.

maneta added 2 commits February 27, 2018 22:02
Calling Write just once

Expanding the t/resolver.t TEST 1 documentation

Updating changelog for spliting `resolv.conf` in lines
@maneta
Copy link
Author

maneta commented Feb 27, 2018

@mikz Rebased

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Fixed

- Error loading policy chain configuration JSON with null value [PR #626](https://github.com/3scale/apicast/pull/626)
- Splitted `resolv.conf` in lines,to avoid commented lines [PR #618](https://github.com/3scale/apicast/pull/618)
Copy link
Contributor

@mikz mikz Feb 27, 2018

Choose a reason for hiding this comment

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

Just a nitpick. Changelog should focus on "what" and not "how".
Here would be better fit: Skip lines starting with a comment when parsing resolv.conf

Copy link
Author

Choose a reason for hiding this comment

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

I bear that in mind. Thanks

@mikz mikz merged commit 7f0b7bb into master Feb 27, 2018
@mikz mikz deleted the fix-resolv-conf-parser branch February 27, 2018 21:10
@mikz
Copy link
Contributor

mikz commented Feb 27, 2018

Thank you @maneta ! Much appreciated.

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

Successfully merging this pull request may close these issues.

3 participants