feat: forward guest DNS to Docker's embedded resolver - #793
Conversation
✅ Deploy Preview for urunc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
25a6350 to
a743f29
Compare
a743f29 to
6723c67
Compare
|
Hey @cmainas, I have implemented the changes we discussed during our sync. Could you please take a look and review them? This will allow us to make any necessary changes before we extend this logic to other unikernels. |
22a5784 to
89b24e6
Compare
cmainas
left a comment
There was a problem hiding this comment.
Hello @alimx07 ,
thank you for all the changes and the fix. A few comments:
- In the e2e testing the docker network does not exist and therefore creating the contianer will fail. We need to setup the network. Maybe in https://github.com/urunc-dev/urunc/blob/main/tests/e2e/docker_test.go#L25 and also remove later.
- Let;s find a better name for loclahost.go. Maybe something like "dns_at_localhost.go"?
- I think I got confused with the
genericRulesanddockerRules. Have we found a case where we should apply thegenericRules(e.g. a CNI) rather thandockerRules? - We can wrap the execution of iptables in a function, instead of having cmd and cmd.Run in various places.
- We should check if we can obtain the information we gather form iptables from other sources (e.g. netlink).
- We can restructure the code and this logic in the network_dynamic.go (the only mode where these changes apply) and avoid re-opening the tap device etc. We can me use of https://github.com/urunc-dev/urunc/blob/main/pkg/network/network_dynamic.go#L23C6-L23C20 for passing information.
- We should also clean up all the rules we apply.
39be2e9 to
7e73541
Compare
| _, err := commonCmdExec(cmdBase) | ||
| return err | ||
| } | ||
|
|
There was a problem hiding this comment.
@cmainas , Regarding network. I think using the same pattern as container (rm , create) is the cleanest way here.
I know this is out of the scope of the PR now, and it just being larger and larger, but what touched here is minimal as possible. Also , a future PR will be opened (by Me) adding more test cases (instead of docker) touching other CLI tools. so if you are good, we can move with this right now.
There was a problem hiding this comment.
It is ok for the time being, let's just make sure we record it so we can fix it later.
| _, err := commonCmdExec(cmdBase) | ||
| return err | ||
| } | ||
|
|
There was a problem hiding this comment.
It is ok for the time being, let's just make sure we record it so we can fix it later.
|
Also, one more thing, do not forget to add yourself in https://github.com/urunc-dev/urunc/blob/main/.github/contributors.yaml |
| return nil | ||
| } | ||
|
|
||
| func uint16Ptr(v uint16) *uint16 { |
There was a problem hiding this comment.
I have tried but it fails everytime.
There was a problem hiding this comment.
What does fail mean? Is it a compiler error, a runtime error, other failure?
There was a problem hiding this comment.
Ptype should be a pointer to uint16. I got a error when trying to do this inline with a pointer operator before uint16.
7e73541 to
b27f329
Compare
|
@cmainas . Everything almost done. Let me if you have any other comments. meanwhile I will be working on sideContainers case for now :) |
|
Hello @alimx07 , please rebase over the main branch. |
b27f329 to
d77880e
Compare
cmainas
left a comment
There was a problem hiding this comment.
Hello @alimx07 , some comments:
- the unit tests need to be added in https://github.com/urunc-dev/urunc/blob/main/Makefile#L236C43-L236C55 so they run though the CI. Check
test_networkhow it is declared and used. - the rebase seems that changed the go.mod file. Also, please avoid merge commits they do not add any value in the git history.
| golang.org/x/net v0.56.0 | ||
| golang.org/x/sys v0.46.0 | ||
| google.golang.org/grpc v1.81.1 | ||
| k8s.io/cri-api v0.36.2 |
There was a problem hiding this comment.
Just random go mod tidy. No problems I revert it now and rebased also :)
| // and set our `loIP` as `127.0.0.10` (first loopback nameserver), | ||
| // which will be the one in TC rules and Iptables one. | ||
| // Knowing that we should only rewrite the first nameserver in our `resolv.conf`, | ||
| // so final result will be : |
| for _, line := range lines { | ||
| fields := strings.Fields(line) | ||
|
|
||
| // if we have `resolv.conf` as : |
9220678 to
f278a84
Compare
|
Hello @alimx07 , the PR does not pass its test. Could you also check the remaining two open comments? |
f278a84 to
e67c01b
Compare
e67c01b to
a2440a9
Compare
Detect first loopback nameserver in our resolv.conf and rewrite to user defined virtIP (configured in urunc constants) and apply some TC rules in general and IP rules (docker case) so we can route this DNS queries to host localhost DNS server. Signed-off-by: Ali Mohamed <amx746@gmail.com>
a2440a9 to
c741409
Compare
|
Tested it locally and seems to work, not sure what is wrong with CI. We need to check this. |
Description
On Docker user custom networks the DNS resolver (127.0.0.11) is loopback only and unreachable by the unikernel guest. Detect this case per container, expose the resolver via a virtual resolver IP
configured by userusing tc redirects between the tap and lo , and rewrite the guest'sresolv.confto point at that IP in our unikernel islinuxone. Also we add a custom rules DNAT rules according to the enviroment (e.g. Docker -> PREROUTING DNAT(for DNS server ports))Two TC rules added on tap and lo:
src=ResolvIPinto TapRelated issues
How was this tested?
Tested in user custom docker network with urunc container
u1and normal oneu2:u1lookup ongithub.comu1lookup onu2u2lookup onu1LLM usage
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).