Skip to content
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

QuantastorClient timeout not configurable #3

Open
singlecheeze opened this issue Oct 14, 2024 · 4 comments
Open

QuantastorClient timeout not configurable #3

singlecheeze opened this issue Oct 14, 2024 · 4 comments

Comments

@singlecheeze
Copy link

For long runnin, non async operations, the client will disconnect before the operation will complete, e.g creating 300 LUNs. I am using QuantaStor array to load test some Kubernetes load testing for k8s CSI.

The only way to the requests timeout of choice is to override the make_call method:

class QC(QuantastorClient):
    def make_call(self, api, payload):
        strURL = self._base_url + api
        certPath = self._cert
        if not path.exists(self._cert) or not self._cert:
            print("Warning - SSL certificate path: '" + str(self._cert) + "' either doesn't exist, or was not given. HTTPS request cannot be verified.")
            certPath = False
        r = requests.get(strURL, params=payload, verify=certPath, auth=self._auth, timeout=1200)
        if r.status_code != 200:
            raise Exception("Failed to make a request '" + api + "' payload '" + str(payload) + "' status code = " + str(r.status_code) + "strUrl " + strURL)
        jsonOutput = r.json()
        if isinstance(jsonOutput, dict) and 'RestError' in jsonOutput:
            raise Exception("Failed to make a request '" + api + "' payload '" + str(payload) + "' RestError = " + jsonOutput['RestError'])
        return jsonOutput

I propose changing the constructor of the client class and just adding a timeout, and if not specified default to requests native timeout:

    def __init__(self, hostname="", username="", password="", cert="", timeout=None):
        self._hostname = hostname
        self._username = username
        self._password = password
        self._cert = cert
        self.tmeout = timeout
@singlecheeze
Copy link
Author

#4

@singlecheeze
Copy link
Author

I am still seeing timeouts even after the above edit Total Call Time: 90.1486s

I even edited /opt/osnexus/quantastor/restsrv/restsrv.py to add a 20 min timeout based on this:

def runService():

    server_config = {
        'server.socket_host': '127.0.0.1',
        'server.socket_port': 5154,
        'tools.trailing_slash.on': False,
        'server.socket_timeout': 1200
    }

    cherrypy.config.update(server_config)

    cherrypy.tree.mount(QSServer(), '/qstorapi')
    cherrypy.tree.mount(QSJSONServer(), '/qstorapi/jsonrpc')
    cherrypy.engine.start()
    cherrypy.engine.block()

@singlecheeze
Copy link
Author

Ah found it, suds needs a timeout set too as jsonRPC just calls SOAP client:

def getClientHandle(username='admin', password='password'):
    global soap_client

    if soap_client is None:
        soap_client = Client(url='file:///opt/osnexus/quantastor/lib/osn.wsdl', location='http://localhost:5152', timeout=1200)

    security = Security()
    token = UsernameToken(username, password)
    security.tokens.append(token)
    soap_client.set_options(wsse=security)

    return soap_client

Once change is made, restart two services:

sudo systemctl restart qs-jsonrpcd.service
sudo systemctl restart quantastor.service

@singlecheeze
Copy link
Author

So in total 3 timeouts need to be configurable, well really two if you want to use the same timeout for jsonRPC and suds (SOAP), and then from the client side requests timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant