-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Add default tll for record #173
feat: Add default tll for record #173
Conversation
Hi, @nobleess, and thank you for your contribution! I think the default TTL should somehow be configurable via env vars by the user. When you deploy the webhook to your cluster, there should be some configurable option to set it. I'm currently on my phone so I haven't looked at the code much, but I'll try to get to it tomorrow. |
0a0b337
to
bec8714
Compare
25828b4
to
99e42b6
Compare
@mircea-pavel-anton I agree with you. I watched how it was implemented in aws.go and tried to repeat solution here. |
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.
Overall I think this is exactly what we need, just some nitpicks on the code structure 😅
Also, some documentation change would also be nice for this. We can add a new section under |
also, CI is failing because of missing bot app credentials, but that is expected. You can lint your go code using |
65cc988
to
f8ce333
Compare
I updated the workflows so they can run on forks as well and rebased this branch to get that update. All workflows seem to pass now |
1e1a14b
to
a5654b4
Compare
internal/mikrotik/provider.go
Outdated
for _, create := range changes.Create { | ||
if !create.RecordTTL.IsConfigured() { | ||
create.RecordTTL = endpoint.TTL(p.client.TTL) | ||
newChanges.Create = append(newChanges.Create, create) | ||
} | ||
} | ||
|
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.
I think I found a new issue here. The check and enforcement of the default ttl is currently only done on record creation. This means that external DNS will create the record with the default ttl correctly, but then at the next loop it will update it back to 0. We should probably do a similar check for updating records
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.
Also, when we are initializing newChanges
a few lines up, we're setting newChanges.Create = changes.Create
. This causes the entire list to be duplicated. We need to set:
newChanges := &plan.Changes{
Create: []*endpoint.Endpoint{},
Delete: changes.Delete,
UpdateOld: []*endpoint.Endpoint{},
UpdateNew: []*endpoint.Endpoint{},
}
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.
This all looks good. Now we just need to fix the issue of injecting the default TTL in updates as well.
Basically the behavior I am seeing right now is that when I create a new record it does get the default TTL set, but then on the next reconciliation loop, it gets set back to 0.
I am not entirely sure where/how to address this. Perhaps in isEndpointMatching
? I'll see if I can think of something too
I played around a bit with the issue on a different branch and I think I got a working proof of concept: https://github.com/mirceanton/external-dns-provider-mikrotik/tree/local-test I haven't tested this extensively, but so far it seems to work. Feel free to adapt any of that code if you think it fits The tests would also need to be updated. Let me know if you can/want to look into that 😁 |
@nobleess that extra condition for the TTLs makes sure that we can also update to/from default ttl from/to other values. For example, without it we would not be able to update from a TTL of 5s to default TTL and vice versa. See here some example tests: https://github.com/mirceanton/external-dns-provider-mikrotik/blob/local-test/internal/mikrotik/provider_test.go#L605-L697 |
90e7afe
to
b2c2687
Compare
@nobleess is this ready for review? |
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.
looks good!
🎉 This PR is included in version 1.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
No description provided.