-
Notifications
You must be signed in to change notification settings - Fork 48
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
Handle existing zone in dynamically addition of DNS records #236
Conversation
5909dd5
to
d80b3a1
Compare
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.
The addition might need to be added slightly differently, see my comments in the PR.
pkg/services/dns/dns.go
Outdated
for i, zone := range s.handler.zones { | ||
if zone.Name == req.Name { | ||
req.Records = append(req.Records, zone.Records...) | ||
s.handler.zones = append(s.handler.zones[:i], s.handler.zones[i+1:]...) |
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.
Not so sure it's a good thing to reorder the zones
list. Let's say the initial state is:
DNS: []types.Zone{
{
Name: "crc.testing.",
DefaultIP: net.ParseIP("192.168.127.2"),
},
{
Name: "testing.",
Records: []types.Record{
{
Name: "host",
IP: net.ParseIP("192.168.127.3"),
},
},
},
},
And I then want to add gateway.testing
:
types.Zone{
{
Name: "testing.",
Records: []types.Record{
{
Name: "gateway",
IP: net.ParseIP("192.168.127.1"),
},
},
After updating the existing zone, testing.
will come before crc.testing.
, and *.crc.testing
will return "not found" instead of resolving to 192.168.127.2
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.
Ah makes sense thanks for the input i missed out this usecase completely :( I will update the PR to maintain the order of zones as well.
Basically,
- We will insert new zones at last (as we are already handling existing zones case)
- For existing zones keep the location same. (Just append Records to existing one and set DefaultIP)
d80b3a1
to
c71dfd2
Compare
@cfergeau Happy to update if any changes are required :) |
8105ff0
to
d024333
Compare
Signed-off-by: Balaji Vijayakumar <kuttibalaji.v6@gmail.com>
d024333
to
d983d11
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: balajiv113, cfergeau The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In #217 i assumed that we are iterating through all zones until we find a record match but that was wrong. If the zone name matches we are returning error if record is not found.
This PR is about handling existing zones to keep the records array in sync.