Skip to content

QuantastorClient timeout not configurable #3

@singlecheeze

Description

@singlecheeze

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions