On 1/9/26 3:14 PM, Eelco Chaudron wrote:
> 
> 
> On 18 Dec 2025, at 11:46, Ilya Maximets wrote:
> 
>> A python counterpart of the following commit:
>>
>>   0b29edb5cbdc ("dns-resolve: Do not treat never accessed responses as 
>> expired.")
>>
>> The same issue exists in the python code where we may never connect
>> to a remote server if our DNS TTL is lower than the backoff interval.
>>
>> Fix it in the same way as we did in C implementation - allow using
>> the entry if it was never used after requesting for up to 5 minutes,
>> as this is not really caching, but a "transaction in progress" type
>> of situation.
>>
>> More details in the commit message for the C version.
> 
> Thanks for also fixing this part. Two nits that can be fixed on commit.
> 
> //Eelco
> 
> Acked-by: Eelco Chaudron <[email protected]>
> 
>> Signed-off-by: Ilya Maximets <[email protected]>
>> ---
>>  python/ovs/dns_resolve.py | 29 ++++++++++++++++++++++++-----
>>  1 file changed, 24 insertions(+), 5 deletions(-)
>>
>> diff --git a/python/ovs/dns_resolve.py b/python/ovs/dns_resolve.py
>> index 41546ad5c..d38e8a658 100644
>> --- a/python/ovs/dns_resolve.py
>> +++ b/python/ovs/dns_resolve.py
>> @@ -29,12 +29,15 @@ import ovs.vlog
>>
>>  vlog = ovs.vlog.Vlog("dns_resolve")
>>
>> +RESOLVE_UNUSED_TIMEOUT = 300  # Seconds.
>> +
>>
>>  class ReqState(enum.Enum):
>>      INVALID = 0
>>      PENDING = 1
>> -    GOOD = 2
>> -    ERROR = 3
>> +    GOOD_UNUSED = 2
>> +    GOOD = 4
>> +    ERROR = 5
> 
> Any reason skipping 3?
>>
>>  class DNSRequest:
>> @@ -48,11 +51,27 @@ class DNSRequest:
>>
>>      @property
>>      def expired(self):
>> -        return time.time() > self.time + self.ttl
>> +        ttl = self.ttl
>> +        # When we just sent a request, but didn't look at the response yet,
>> +        # it's not caching, but a "transaction in progress" situation, so we
>> +        # can use the response even with TTL of 0 and more than 1 second
>> +        # passed.  Allow such values to be accessed for at least
>> +        # RESOLVE_UNUSED_TIMEOUT seconds without considering them stale.
>> +        # This is necessary in case of large backoff intervals on 
>> connections
>> +        # or if the process is doing some other work not looking at the
>> +        # response for longer than TTL. */
> 
> It still has a C-style end of comment.

Oops.  Thanks for noticing these two things!  I clearly pushed 'send' a little
too fast on this one.  I fixed them up and applied the change.  Backported
down to 3.3.

Best regards, Ilya Maximets.
the change.  Ba
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to