<div dir="ltr">Hi Thomas:<div><br></div><div>If I'm not wrong, the goal of this filtering is to remove all those subnets with service_type='network:routed'. Maybe you can check implementing an easier query:</div><div>SELECT subnets.segment_id AS subnets_segment_id <br>FROM subnets <br>WHERE subnets.network_id = %(network_id_1)s AND NOT (EXISTS (SELECT * <br>FROM subnet_service_types <br>WHERE <a href="http://subnets.id">subnets.id</a> = subnet_service_types.subnet_id AND subnet_service_types.service_type = %(service_type_1)s))<br></div><div><br></div><div>That will be translated to python as:</div><div><pre style="background-color:rgb(239,239,239);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">query = test_db.context.session.query(subnet_obj.Subnet.db_model.segment_id)<br>query = query.filter(subnet_obj.Subnet.db_model.network_id == network_id)<br><span style="color:rgb(0,0,128);font-weight:bold">if </span>filtered_service_type:<br><span style="color:rgb(128,128,128);font-style:italic"> </span>query = query.filter(~exists().where(and_(<br> <a href="http://subnet_obj.Subnet.db_model.id">subnet_obj.Subnet.db_model.id</a> == service_type_model.subnet_id,<br><span style="color:rgb(128,128,128);font-style:italic"> </span>service_type_model.service_type == filtered_service_type)))</pre></div><div>Can you provide a UTs or a way to check the problem you are experiencing?</div><div><br></div><div>Regards.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 15, 2020 at 1:27 PM Thomas Goirand <<a href="mailto:zigo@debian.org">zigo@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Sending the message again with the correct From, as I'm not subscribed<br>
to the list with the other mailbox.<br>
<br>
On 7/15/20 2:13 PM, Thomas Goirand wrote:<br>
> Hi Ryan,<br>
> <br>
> If you don't mind, I'm adding the openstack-discuss list in the loop, as<br>
> this topic may be of interest to others.<br>
> <br>
> For mailing list readers, I'm trying to implement this:<br>
> <a href="https://review.opendev.org/#/c/669395/" rel="noreferrer" target="_blank">https://review.opendev.org/#/c/669395/</a><br>
> but I'm having some difficulties.<br>
> <br>
> I did a bit of investigation with some added LOG.info() in the code.<br>
> <br>
> When doing:<br>
> <br>
>> openstack subnet create vm-fip \<br>
>> --subnet-range <a href="http://10.66.20.0/24" rel="noreferrer" target="_blank">10.66.20.0/24</a> \<br>
>> --service-type 'network:routed' \<br>
>> --service-type 'network:floatingip' \<br>
>> --network multisegment1<br>
> <br>
> Here's where neutron-api crashes. in db/ipam_backend_mixin.py:<br>
> <br>
> def _validate_segment(self, context, network_id, segment_id,<br>
> action=None,<br>
> old_segment_id=None):<br>
> # TODO(tidwellr) Create and use a constant for the service type<br>
> segments = subnet_obj.Subnet.get_subnet_segment_ids(<br>
> context, network_id, filtered_service_type='network:routed')<br>
> <br>
> associated_segments = set(segments)<br>
> if None in associated_segments and len(associated_segments) > 1:<br>
> raise segment_exc.SubnetsNotAllAssociatedWithSegments(<br>
> network_id=network_id)<br>
> <br>
> SubnetsNotAllAssociatedWithSegments() is raised, as you must already<br>
> guessed. Here's the values...<br>
> <br>
> associated_segments is an array containing 3 values: 2 being the IDs of<br>
> the segments I added previously, the 3rd one being None. This test is<br>
> then matched. Where is that None value coming from? Is this the new<br>
> subnet I'm trying to add? Maybe the<br>
> filtered_service_type='network:routed' in the call:<br>
> subnet_obj.Subnet.get_subnet_segment_ids() isn't working as expected?<br>
> <br>
> Printing the SQL query that is checked shows:<br>
> <br>
> SELECT subnets.segment_id AS subnets_segment_id FROM subnets<br>
> WHERE subnets.network_id = %(network_id_1)s AND <a href="http://subnets.id" rel="noreferrer" target="_blank">subnets.id</a> NOT IN<br>
> (SELECT subnet_service_types.subnet_id AS subnet_service_types_subnet_id<br>
> FROM subnet_service_types<br>
> WHERE subnets.network_id = %(network_id_2)s AND<br>
> subnet_service_types.subnet_id = <a href="http://subnets.id" rel="noreferrer" target="_blank">subnets.id</a> AND<br>
> subnet_service_types.service_type = %(service_type_1)s)<br>
> <br>
> though when doing by hand:<br>
> <br>
> SELECT subnets.segment_id AS subnets_segment_id FROM subnets<br>
> <br>
> the db has only 2 subnets, so it looks like the floating-ip subnet got<br>
> added before the check, and is then removed when the above test fails.<br>
> <br>
> So I just removed the raise, and could add the subnet I wanted, but<br>
> that's obviously not a long term solution.<br>
> <br>
> Your thoughts?<br>
> <br>
> Another problem that I'm having, is that neutron-bgp-dragent is not<br>
> receiving (or processing) the messages from neutron-rpc-server. I've<br>
> enabled DEBUG mode for oslo_messaging, and found out that when dr-agent<br>
> starts and prints "Agent has just been revived. Scheduling full sync",<br>
> it does send a message to neutron-rpc-server, which is replied, but it<br>
> doesn't look like dr-agent processes the return message in its reply<br>
> queue, and then prints in the logs: "imeout in RPC method<br>
> get_bgp_speakers. Waiting for 17 seconds before next attempt. If the<br>
> server is not down, consider increasing the rpc_response_timeout option<br>
> as Neutron server(s) may be overloaded and unable to respond quickly<br>
> enough.: oslo_messaging.exceptions.MessagingTimeout: Timed out waiting<br>
> for a reply to message ID c1b401c9e10d481bb5e071f2c048e480". What is<br>
> weird is that a few times (rarely), it worked, and the agent gets the reply.<br>
> <br>
> What should I do to investigate further?<br>
> <br>
> Cheers,<br>
> <br>
> Thomas Goirand (zigo)<br>
> <br>
<br>
<br>
</blockquote></div>