GithubHelp home page GithubHelp logo

hpe-storage / nimble-golang-sdk Goto Github PK

View Code? Open in Web Editor NEW
5.0 9.0 11.0 3.41 MB

Go Software Development Kit (SDK) for HPE Nimble Storage Arrays

License: Apache License 2.0

Go 100.00%
nimble sdk go hpe array api rest-api https

nimble-golang-sdk's Issues

Enhance support of Pagination

  • We need to enhance pagination support similar to Python SDK

  • The pagination for list output can be handled better without exposing startRow and endRow to the user.

  • The idea here is to eliminate startRow and endRow from the SDK so that the users needs not worry about the specifying those parameters explicitly and also avoid dealing with those parameters.

  • Instead, we can expose the pagination functionality in a simpler way with only two parameters:

  1. limit (This is typically page size which returns the first N entries).
  2. from_id (This is the typically the last id retrieved from the previous get(limit=N) response.

Please refer to the example in Python SDK:
https://hpe-storage.github.io/nimble-python-sdk/get_started/using/index.html#pagination

Querying snapshots by Volume Name

NOTE: This behavior is observed on the master branch as of Aug 5, 2021.

I found an issue when querying for snapshots by Volume Name when the volume name contains characters unsafe for URL's. In the event that a volume name contains something like :, which is not url safe, the SDK will convert the request to an advanced search.

This advanced search request is rejected by the SAN.

Here is an example of the code snip-it:

	params := &param.GetParams{
		Filter: &param.SearchFilter{
			Criteria: []*param.SearchFilter{
				{FieldName: &nimbleos.SnapshotFields.VolName, Operator: param.EQUALS.String(), Value: *vol.Name},
				{FieldName: &nimbleos.SnapshotFields.IsManuallyManaged, Operator: param.EQUALS.String(), Value: "true"},
			},
		},
	}
	snaps, err := service.GetSnapshotService().GetSnapshots(params)

Here is the REST API debug log:

==============================================================================
Volume: SERVER-Data-Daily-7-Day-2021-10-26::20:41:18.409:EDT
2021/11/23 14:39:43.863943 DEBUG RESTY 
==============================================================================
~~~ REQUEST ~~~
POST  /v1/snapshots/detail  HTTP/1.1
HOST   : x.x.x.x:5392
HEADERS:
	Content-Type: application/json
	User-Agent: go-resty/2.6.0 (https://github.com/go-resty/resty)
	X-Auth-Token: 32aa460f44d0a95ee57982c92a71f47e
BODY   :
{
   "data": {
      "_constructor": "AdvancedCriteria",
      "operator": "",
      "criteria": [
         {
            "fieldName": "vol_name",
            "operator": "equals",
            "value": "SERVER-Data-Daily-7-Day-2021-10-26::20:41:18.409:EDT"
         },
         {
            "fieldName": "is_manually_managed",
            "operator": "equals",
            "value": "true"
         }
      ]
   },
   "operationType": "fetch"
}
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS       : 400 OK
PROTO        : HTTP/1.1
RECEIVED AT  : 2021-11-23T14:39:43.863640016-05:00
TIME DURATION: 42.352938ms
HEADERS      :
	Connection: Keep-Alive
	Content-Type: application/json;charset=utf-8
	Date: Tue, 23 Nov 2021 19:39:43 GMT
BODY         :
{
   "messages": [
      {
         "code": "SM_http_bad_request",
         "severity": "error",
         "text": "The request could not be understood by the server."
      },
      {
         "code": "SM_unsupported_query_operator",
         "severity": "error",
         "arguments": {
            "field": "AdvancedCriteria",
            "op": ""
         },
         "text": "Unsupported filter operator '' specified for the attribute 'AdvancedCriteria'."
      }
   ]
}

Automatic token refresh does not work. Need to update vendored version of rusty

I have experienced that when the auth token expires in a long running application, the SDK does not retry the failed operation after token refresh. Instead, after refreshing the token, it returns the error from the original failed attempt.

I did some digging and it turns out that the root cause is actually an off-by-one error the vendored version of resty v2.2.0. This bug was fixed in v2.3.0.

The max retries are set in pkg/client/group_mgmt_client.go

const (
...
	maxLoginRetries   = 1
...
)

and used https://github.com/hpe-storage/nimble-golang-sdk/blob/master/pkg/client/group_mgmt_client.go#L130

// NewClient instantiates a new client to communicate with the Nimble group
func NewClient(ipAddress, username, password, apiVersion string, waitOnJobs, isTenant bool, tlsConfig *tls.Config) (*GroupMgmtClient, error) {
...
	// Add a retry condition to perform a relogin if the session has expired
	groupMgmtClient.Client.
		AddRetryCondition(
...
		).SetRetryCount(maxLoginRetries)  <<<<-------
...
}

The bug in resty counts the original request as one of the retry attempts, so that a RetryCount of 1 will only make the first request and upon retry it exits because it has exhausted the RetryCount.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.