hpe-storage / nimble-golang-sdk Goto Github PK
View Code? Open in Web Editor NEWGo Software Development Kit (SDK) for HPE Nimble Storage Arrays
License: Apache License 2.0
Go Software Development Kit (SDK) for HPE Nimble Storage Arrays
License: Apache License 2.0
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:
Please refer to the example in Python SDK:
https://hpe-storage.github.io/nimble-python-sdk/get_started/using/index.html#pagination
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 := ¶m.GetParams{
Filter: ¶m.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'."
}
]
}
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.