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

DHCP and MikrotikResourceDataToTerraform #110

Closed
durandguru opened this issue Feb 16, 2023 · 17 comments · Fixed by #111, #117, #125 or #131
Closed

DHCP and MikrotikResourceDataToTerraform #110

durandguru opened this issue Feb 16, 2023 · 17 comments · Fixed by #111, #117, #125 or #131
Assignees
Labels
bug Something isn't working In Progress The issue is currently in progress released

Comments

@durandguru
Copy link
Contributor

Describe the bug
Set DHCP reservations via routeros_ip_dhcp_server_lease. If the fields Active MAC Address, Active Hostname and Expires After are filled by an active reservation this error appears.

BTW I Love what you guys are doing with this provider! I find it very useful.

To Reproduce
resource "routeros_ip_dhcp_server_lease" "vlan-112-gs-cu-03" {
address = "172.22.112.103"
mac_address = "00:1D:C1:94:87:42"
server = routeros_dhcp_server.vlan-112-dhcp-server.name
comment = "GS-CU-03"
}

Additional context
Different output because of a lot of warnings:
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-16T22:24:52.168451+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: active_mac_address \u003c\u003c\u003c= 00:1D:C1:94:87:42","address":"routeros_ip_dhcp_server_lease.vlan-112-gs-cu-03","range":{"filename":"vlan-112-dante.tf","start":{"line":95,"column":62,"byte":2971},"end":{"line":95,"column":63,"byte":2972}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-112-gs-cu-03"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-112-gs-cu-03" {","start_line":95,"highlight_start_offset":61,"highlight_end_offset":62,"values":[]}},"type":"diagnostic"}

{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-16T22:24:52.168451+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: active_mac_address \u003c\u003c\u003c= 00:1D:C1:94:87:42","address":"routeros_ip_dhcp_server_lease.vlan-112-gs-cu-03","range":{"filename":"vlan-112-dante.tf","start":{"line":95,"column":62,"byte":2971},"end":{"line":95,"column":63,"byte":2972}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-112-gs-cu-03"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-112-gs-cu-03" {","start_line":95,"highlight_start_offset":61,"highlight_end_offset":62,"values":[]}},"type":"diagnostic"}

image

@durandguru durandguru added the bug Something isn't working label Feb 16, 2023
@gfenn-newbury
Copy link
Collaborator

So just to confirm the steps to reproduce this:

  • Create static lease
  • Lease gets obtained, which populates "Active Address", "Active MAC Address" and "Active Hostname"
  • Provider throws error on next plan until lease is released

Does that sound right?

@gfenn-newbury gfenn-newbury added under review Issue is being reviewed and tested In Progress The issue is currently in progress and removed under review Issue is being reviewed and tested labels Feb 17, 2023
gfenn-newbury added a commit that referenced this issue Feb 17, 2023
fix(#110): Add missing fields to DhcpServerLease
@github-actions
Copy link

🎉 This issue has been resolved in version 1.0.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@durandguru
Copy link
Contributor Author

Thanks, for the quick fix! I checked again with 1.06 and we are still missing the fields active_server, active_client_id, expires_after, host_name

I missed those yesterday, but I had about 60 of these messages and yesterday recreated with the gnewbury resource name, and today the devices became active again.

{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-17T20:39:56.350510+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: active_server \u003c\u003c\u003c= vlan-108-ndi-production","address":"routeros_ip_dhcp_server_lease.vlan-108-vmix-b","range":{"filename":"vlan-108-ndi-production.tf","start":{"line":57,"column":60,"byte":1678},"end":{"line":57,"column":61,"byte":1679}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-108-vmix-b"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-108-vmix-b" {","start_line":57,"highlight_start_offset":59,"highlight_end_offset":60,"values":[]}},"type":"diagnostic"}
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-17T20:39:56.359270+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: active_client_id \u003c\u003c\u003c= 1:1c:b3:c9:b:51:30","address":"routeros_ip_dhcp_server_lease.vlan-108-atv-04","range":{"filename":"vlan-108-ndi-production.tf","start":{"line":275,"column":60,"byte":8912},"end":{"line":275,"column":61,"byte":8913}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-108-atv-04"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-108-atv-04" {","start_line":275,"highlight_start_offset":59,"highlight_end_offset":60,"values":[]}},"type":"diagnostic"}
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-17T20:39:56.343379+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: expires_after \u003c\u003c\u003c= 14h40m41s","address":"routeros_ip_dhcp_server_lease.vlan-20-au-printer-01","range":{"filename":"vlan-20-loc.tf","start":{"line":50,"column":66,"byte":1411},"end":{"line":50,"column":67,"byte":1412}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-20-au-printer-01"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-20-au-printer-01" {","start_line":50,"highlight_start_offset":65,"highlight_end_offset":66,"values":[]}},"type":"diagnostic"}
108-aida-01" {","start_line":78,"highlight_start_offset":60,"highlight_end_offset":61,"values":[]}},"type":"diagnostic"}
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-17T20:39:56.238272+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: host_name \u003c\u003c\u003c= WAP03","address":"routeros_ip_dhcp_server_lease.vlan-10-wap03","range":{"filename":"vlan-10-management.tf","start":{"line":84,"column":58,"byte":2422},"end":{"line":84,"column":59,"byte":2423}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-10-wap03"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-10-wap03" {","start_line":84,"highlight_start_offset":57,"highlight_end_offset":58,"values":[]}},"type":"diagnostic"}

@gfenn-newbury
Copy link
Collaborator

@durandguru could you check with version 1.0.7, please? I know @vaerh made some changes to the fields of the dhcp lease with #114

@github-actions
Copy link

🎉 This issue has been resolved in version 1.0.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh
Copy link
Collaborator

vaerh commented Feb 20, 2023

@durandguru could you check with version 1.0.7, please? I know @vaerh made some changes to the fields of the dhcp lease with #114

I saw the difference in the writing of these fields, but for some reason I missed the old one?!? The RouterOS documentation sometimes disagrees with the actual names.

@durandguru
Copy link
Contributor Author

In 1.0.7 I get the error:
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-20T10:12:04.932112+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: host_name \u003c\u003c\u003c= LocalHost","address":"routeros_ip_dhcp_server_lease.vlan-100-cam-05","range":{"filename":"vlan-100-video-referee.tf","start":{"line":71,"column":60,"byte":2133},"end":{"line":71,"column":61,"byte":2134}},"snippet":{"context":"resource "routeros_ip_dhcp_server_lease" "vlan-100-cam-05"","code":"resource "routeros_ip_dhcp_server_lease" "vlan-100-cam-05" {","start_line":71,"highlight_start_offset":59,"highlight_end_offset":60,"values":[]}},"type":"diagnostic"}

In 1.0.8 I do not get an error. But terraform wants to change the hostname. As far as i know this hostname is supplied by the client when it requests a dhcp lease. So I don't know this value beforehand. I think we need to treat it as a data source

routeros_ip_dhcp_server_lease.vlan-100-cam-05 will be updated in-place

~ resource "routeros_ip_dhcp_server_lease" "vlan-100-cam-05" {
- host_name = "LocalHost" -> null
id = "*2BE"
# (17 unchanged attributes hidden)
}

image

@vaerh vaerh reopened this Feb 20, 2023
vaerh added a commit that referenced this issue Feb 20, 2023
fix: #110 Added "detail" field & "host_name" set to computed.
vaerh added a commit that referenced this issue Feb 20, 2023
@github-actions
Copy link

🎉 This issue has been resolved in version 1.0.9 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@durandguru
Copy link
Contributor Author

Almost all the errors are gone 1.0.11.

Still got this one:
{"@Level":"warn","@message":"Warning: Field not found","@module":"terraform.ui","@timestamp":"2023-02-22T13:20:32.792191+01:00","diagnostic":{"severity":"warning","summary":"Field not found","detail":"[MikrotikResourceDataToTerraform] The field was lost during the Schema development: bootp_support \u003c\u003c\u003c= none","address":"routeros_dhcp_server.vlan-40-dhcp-server","range":{"filename":"vlan-40-iot.tf","start":{"line":30,"column":55,"byte":781},"end":{"line":30,"column":56,"byte":782}},"snippet":{"context":"resource "routeros_dhcp_server" "vlan-40-dhcp-server"","code":"resource "routeros_dhcp_server" "vlan-40-dhcp-server" {","start_line":30,"highlight_start_offset":54,"highlight_end_offset":55,"values":[]}},"type":"diagnostic"}

@vaerh
Copy link
Collaborator

vaerh commented Feb 22, 2023

Where do you get these fileds? 😭 Synthetic tests look just fine.
Thanks for your help, I'll fix it a little later.

@durandguru
Copy link
Contributor Author

Thanks for the fixing. I just do some basic config. Some fields pop-up after others are fixed.

@vaerh
Copy link
Collaborator

vaerh commented Feb 22, 2023

And this is a very interesting idea, I have a feeling that TF does not report all the fields that are missing in the schema, although it sees them. Need to check!

@durandguru
Copy link
Contributor Author

I have created a new bug for routeros_interface_list_member, for this i found 2 missing fields, but in the terraform plan -json output it is missing these fields on different resources. So it probably sees 1 and then skips all others for that resource.

@vaerh
Copy link
Collaborator

vaerh commented Feb 22, 2023

Ок, today I will try to reproduce this problem and fix it. Thank you very much!

@vaerh vaerh self-assigned this Feb 22, 2023
vaerh added a commit that referenced this issue Feb 22, 2023
@vaerh vaerh mentioned this issue Feb 22, 2023
vaerh added a commit that referenced this issue Feb 22, 2023
@github-actions
Copy link

🎉 This issue has been resolved in version 1.0.12 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh vaerh reopened this Feb 22, 2023
@durandguru
Copy link
Contributor Author

All the other errors are gone in 1.0.12 ;-) I think the default value of bootp_support must be "static", null is not accepted. Static is the default value if you create an dhcp server in winbox.

routeros_dhcp_server.vlan-20-dhcp-server will be updated in-place

~ resource "routeros_dhcp_server" "vlan-20-dhcp-server" {
- bootp_support = "none" -> null
id = "vlan-20-servers-hosts"
name = "vlan-20-servers-hosts"
# (8 unchanged attributes hidden)
}

@gfenn-newbury
Copy link
Collaborator

🎉 This issue has been resolved in version 1.1.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment