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

Some boolean params can't be reset and the provider does not understand the value #253

Closed
KuxaBeast opened this issue Sep 15, 2023 · 5 comments · Fixed by #269
Closed

Some boolean params can't be reset and the provider does not understand the value #253

KuxaBeast opened this issue Sep 15, 2023 · 5 comments · Fixed by #269
Assignees
Labels
bug Something isn't working released

Comments

@KuxaBeast
Copy link

KuxaBeast commented Sep 15, 2023

Describe the bug
On some boolean fields of some resources the value can't be set to false and the provider does not understand the current value. This issue originates from the fact, that in the RouterOS API not all booleans are treated the same way and some need to be "unset" instead of "set" to "false". One instance is the passive parameter on the routeros_routing_ospf_interface_template resource.

The problem resides in the handling of boolean values in the data serialization code, which does not differentiate between classic boolean states and these set/unset params. This behaviour can clearly be seen in the behaviour in the ROS console or API:

[admin@Lain] > /routing ospf interface-template
[admin@Lain] > set *D passive
[admin@Lain] > print terse show-ids proplist=area,type,cost,passive where .id=*D
*D area=area-ospfv2 type=broadcast cost=1 passive
[admin@Lain] > set *D !passive
[admin@Lain] > print terse show-ids proplist=area,type,cost,passive where .id=*D
*D area=area-ospfv2 type=broadcast cost=1

In case of the REST API, it's just a matter of prefixing the PATCH's data map key with "!" to unset the value. The set/unset status is reflected in the existence of the parameter in the response json, not on its value.

@KuxaBeast KuxaBeast added the bug Something isn't working label Sep 15, 2023
@KuxaBeast KuxaBeast changed the title Some boolean can' reset and provider does Some boolean can't be reset and the provider does not understand the value Sep 15, 2023
@KuxaBeast KuxaBeast changed the title Some boolean can't be reset and the provider does not understand the value Some boolean params can't be reset and the provider does not understand the value Sep 15, 2023
@vaerh
Copy link
Collaborator

vaerh commented Sep 18, 2023

Hi!
Yes, unfortunately I have encountered this behavior of MT resources. The only solution I can think of is to force recreate the resource. I will take a look at your situation on my lab and see what can be done.

@KuxaBeast
Copy link
Author

Can't this be somehow mitigated? This behavior is predictable by checking the resource parameters' table on the ROS docs/wiki (instead of yes/no, there is an empty "()" datatype). If we were to somehow implement a secondary boolean type to handle these kind of parameters, or just somehow make a toggle and annotate the affected resources in the provider code base, to handle the API differently? I am just speculating here, though. I don't know the intricacies of Go and what flexibility does the Terraform provider SDK allow...
Thanks for looking into this.

@vaerh
Copy link
Collaborator

vaerh commented Sep 19, 2023

Let's just say that if a fix needs to be released quickly, only a forced recreation of the resource is the way to go. If there is no hurry, we can try (with no guarantee that everything will work quickly and well) to annotate the fields requiring unset. But! this will require serious changes in the main code, which is responsible for converting TF and MT parameters.

@vaerh
Copy link
Collaborator

vaerh commented Sep 27, 2023

In the best tradition of MT:
изображение

@vaerh vaerh self-assigned this Sep 28, 2023
vaerh added a commit that referenced this issue Sep 28, 2023
vaerh added a commit that referenced this issue Oct 31, 2023
@vaerh
Copy link
Collaborator

vaerh commented Nov 2, 2023

🎉 This issue has been resolved in version 1.20.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@vaerh vaerh added the released label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants