-
Notifications
You must be signed in to change notification settings - Fork 73
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
NodebalancerNode not found. #97
Comments
Looks like it's not you - I'm missing a like in my |
This should be fixed in |
@Dorthu , thanks. It went ok. But, it didn't update the weight. And save returns true, though. |
when I run the excerpt above, I get the following error: ApiError: 400: must be of type Integer; This is probably correct - try setting |
Hmm.. actaully, what I ran was this: import linode
nb_node = linode.NodeBalancerNode(client, xxx, xxx, xxxx) # linode_client, node_id, config_id, nodebalancer_id
nb_node.weight # checked what it was initially in my python shell
nb_node.weight = '100'
nb_node.save() If I don't check it first, then I can reproduce the behavior you're seeing. I'm looking into it now. |
You're right. This time was mistake. I'll check it again. Sorry! |
@Dorthu , here a test that i did: |
Yeah, I think this has something to do with how this library lazy-loads data - accessing an attribute of an api model class that hasn't been loaded yet will issue an api request and populate all attributes of the model (since they all come back). I think that setting the weight is not triggering it to be populated (correctly), but saving the model for some reason is triggering an api request/population, which overrides the values set previously (and thereby doesn't save anything). This is supported by the test you did (on line 28 you don't access any attributes of nb_node, and that node's weight didn't change, but on line 36 you do access an attribute, and that node's weight does change). I'm going to take a look at the code for saving objects and make sure it doesn't trigger a population in the process. Thanks for the details, they made this a lot easier to identify. |
This reproduces the issue described in #97, when saving an unpopulated object apparently triggers population before sending the PUT request. Fix coming soon.
I reproduced this issue in the tests - it looks like this is unique to models that have a derived base class, or possibly unique only to NodeBalancerNode. I'm going to try to get a fix up shortly. |
) ## 📝 Description Previously, attempting to update a non-populated NodeBalancerNode would result in the update actually updating the resource silently. This change fixes the issue. ## ✔️ How to Test `pytest test` Note: Since this change deals with making updates to real resources as opposed to fixtures, it cannot be tested using mocks and must therefore be tested manually. To do this, first create a NodeBalancerNode in your Linode account if one does not already exist, and then run this python script and verify that the weight of the node was actually updated. ``` #!/usr/bin/env python3 from linode_api4 import LinodeClient from linode_api4.objects import NodeBalancerNode client = LinodeClient(<personal_access_token>) node = NodeBalancerNode(client, <node_id>, <config_id>, <nodebalancer_id>) node.weight = 60 node.save() ``` Resolves #97
Hi, i was testing this, as describe in the documentation.
It returned this error:
Traceback (most recent call last):
File "linode_script.py", line 26, in
nb_node = linode.NodeBalancerNode(client, xxx, xxx, xxxx) # linode_client, node_id, config_id, nodebalancer_id
AttributeError: module 'linode' has no attribute 'NodeBalancerNode'
What am i doing wrong?
Thanks.
The text was updated successfully, but these errors were encountered: