akarneliuk / pygnmi

The pure Python implementation of the gNMI client.
https://training.karneliuk.com
BSD 3-Clause "New" or "Revised" License
129 stars 44 forks source link

handle case where QOS marking is not supported #101

Closed ipmonk closed 1 year ago

ipmonk commented 2 years ago

Connecting to a Juniper box running Junos: 21.4R2-S1.12-EVO which doesn't support qos marking in the request

# Modules
from pygnmi.client import gNMIclient, telemetryParser

# Variables
host = ('1.1.1.1', '50051')

# Body
subscribe = {
    'subscription': [
        {
            'path': '/components/component',
            'mode': 'sample',
            'sample_interval': 10000000000
        },
    ],
    'use_aliases': False,
    'mode': 'stream',
    'encoding': 'json'
}

if __name__ == '__main__':
    with gNMIclient(target=host, username='foo', password='lab123', insecure=True) as gc:
        telemetry_stream = gc.subscribe_stream(subscribe=subscribe)
        for telemetry_entry in telemetry_stream:
            print(telemetry_entry)
Exception in thread Thread-5:
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/foo/scripts/foo/gnmi-scripts/venv/lib/python3.9/site-packages/pygnmi/client.py", line 908, in enqueue_updates
    for update in subscription:
  File "/Users/foo/scripts/foo/gnmi-scripts/venv/lib/python3.9/site-packages/grpc/_channel.py", line 426, in __next__
    return self._next()
  File "/Users/foo/scripts/foo/gnmi-scripts/venv/lib/python3.9/site-packages/grpc/_channel.py", line 826, in _next
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
    status = StatusCode.UNIMPLEMENTED
    details = "Qos not supported"
    debug_error_string = "UNKNOWN:Error received from peer ipv4:1.1.1.1:50051 {created_time:"2022-10-25T17:54:09.501974+11:00", grpc_status:12, grpc_message:"Qos not supported"}

commenting out this line in client.py allows it to proceed:

        # Create message for eveyrhting besides subscriptions
        request = SubscriptionList(prefix=gnmi_path_generator(subscribe['prefix'], target),
                                   use_aliases=subscribe['use_aliases'],
#                                   qos=subscribe['qos'],  <<<<
akarneliuk commented 2 years ago

Hey @ipmonk ,

well, that's again seem to be bug of Juniper (or to be precise, the way they implement GNMI). I haven't seen such an issue in any other vendor. I don't think that commenting this line is a right way forward. I will see if there is way do that more logical and not Juniper-specific.

Best, Anton

akarneliuk commented 1 year ago

Thanks for contributing @ipmonk