opendevreview | Sunday Mgbogu proposed openstack/kuryr-kubernetes master: wip: Loadbalancers reconciliation https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904 | 06:49 |
---|---|---|
digitalsimboja | @ltomasbo: I need more on list compression | 07:02 |
digitalsimboja | You mean multiple for-loop? | 07:02 |
ltomasbo | digitalsimboja, good morning | 07:05 |
ltomasbo | I mean instead of having the 2 for loops one after another | 07:06 |
digitalsimboja | okay | 07:06 |
ltomasbo | look for python list comprehension in google to check what it is, if you don't know about it | 07:06 |
ltomasbo | it is basicallyl to speed up the processing of going through both for loops | 07:06 |
digitalsimboja | Okay, got it! | 07:06 |
ltomasbo | and to have it in a more compress format | 07:06 |
digitalsimboja | sure | 07:28 |
opendevreview | Sunday Mgbogu proposed openstack/kuryr-kubernetes master: Added the Service Creation Flow Diagram https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798064 | 07:43 |
digitalsimboja | @ltomasbo, @maysams: I am having a little challenge. Initially, this was not occuring so I wonder why | 11:20 |
digitalsimboja | When I want to fetch the loadbalancers from OpenStack, it stores it on a memory | 11:21 |
digitalsimboja | Now I need to see the contents by selecting the 'id' but its reporting that *** TypeError: 'generator' object is not subscriptable | 11:21 |
digitalsimboja | lbaas.load_balancers() | 11:21 |
digitalsimboja | <generator object Resource.list at 0x7ffb9de596d0> | 11:21 |
digitalsimboja | lbaas = clients.get_loadbalancer.client() | 11:23 |
digitalsimboja | loadbalancers = lbaas.load_balancer() | 11:23 |
digitalsimboja | Please take a look | 11:24 |
digitalsimboja | http://paste.openstack.org/show/807099/ | 11:24 |
ltomasbo | digitalsimboja, it is telling you you are using the "for loadbalancer in loadbalancers['id']:" wrongly | 11:50 |
ltomasbo | with python you can inspect the methods an object has with dir | 11:51 |
ltomasbo | dir(loadbalancers) | 11:51 |
digitalsimboja | checking.. | 11:51 |
ltomasbo | note loadbalancers will have the dict with all the loadbalanacers | 11:51 |
ltomasbo | so doing loadbalancers['id'] is wong | 11:51 |
ltomasbo | wrong | 11:51 |
ltomasbo | you need to first get one of the loadbalancers from the loadbalancers and later get the id | 11:52 |
ltomasbo | for the specific loadbalanacer, not over the loadbalancer object | 11:52 |
maysams | digitalsimboja: loadbalancers is a generator https://realpython.com/introduction-to-python-generators/#using-generators | 12:00 |
digitalsimboja | Got it! | 12:00 |
opendevreview | Sunday Mgbogu proposed openstack/kuryr-kubernetes master: wip: Loadbalancers reconciliation https://review.opendev.org/c/openstack/kuryr-kubernetes/+/798904 | 12:45 |
digitalsimboja | Hello! | 13:13 |
digitalsimboja | loadbalancers_id not in lbs_id | 13:13 |
digitalsimboja | http://paste.openstack.org/show/807104/ | 13:14 |
digitalsimboja | Just a little clarification: loadbalancers_id is fetched from Octavia while lbs_id is from kubernetes CRD, I was to check if there are loadbalancers_id not in lbs_id or the other way around lbs_id 'not in' loadbalancers_id ? | 13:16 |
digitalsimboja | Still confusing...? | 13:16 |
digitalsimboja | Right now I have deleted the 'test' loadbalancers on OpenStack ... but its still available on KuryrCRD | 13:18 |
digitalsimboja | So I am supposing I was to check if lbs_id not in loadbalancers_id | 13:18 |
digitalsimboja | @ltomasbo, @maysams: Please clarify | 13:19 |
ltomasbo | digitalsimboja, you need to check if the loadbalancer ID annotated on the CRD status still exists on the OpenStack side | 13:20 |
digitalsimboja | http://paste.openstack.org/show/807106/ | 13:20 |
digitalsimboja | so it should be lbs_id not in loadbalancers_id | 13:20 |
ltomasbo | and if it does not exists on OpenStack side, then remove it from the status so that the reconcile is trigger and a new openstack loadbalancer is generated | 13:20 |
digitalsimboja | correct | 13:20 |
digitalsimboja | lbs_id represents the lb in CRD, while loadbalancers_id represents the lb in OpenStack | 13:21 |
maysams | digitalsimboja: You're checking if a list is not present on another list "if loadbalancers_id not in lbs_id:" | 13:21 |
ltomasbo | digitalsimboja, if you are confuse with your own vars name... that means that perhaps you should rename them to something more meaninful... lbs_id or loadbalancer_id does not make it clear to know if they are the id on the CRD or on the openstack side | 13:21 |
ltomasbo | and... you don't need an if... you need a for loop | 13:22 |
maysams | digitalsimboja: I'm assuming that is not what you wanted to check | 13:22 |
digitalsimboja | Yeah I need to iterate over each item | 13:22 |
ltomasbo | yep, exactly what maysams said! XD | 13:23 |
digitalsimboja | yeah for loop | 13:23 |
digitalsimboja | So I would be picking the items from OpenStack loadbalancers_id and checking them with CRD | 13:24 |
digitalsimboja | Let me work on that then | 13:24 |
maysams | digitalsimboja: always make use of logs at each step, it will be extremely helpful to avoid errors like this. Also, adding comments to code itself is useful to organize it | 13:24 |
ltomasbo | digitalsimboja, I think you need to do it the other way around | 13:25 |
ltomasbo | you need to check if the loadbalancer ID annnotated on the CRD exists on the OpenStack side | 13:25 |
digitalsimboja | Okay got it | 13:26 |
digitalsimboja | @maysams Sure! | 13:26 |
Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!