introduce ability to serial api access, allow toggle settle
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
ff73606b55
commit
eb2bb1dc01
|
|
@ -8,6 +8,7 @@ class SynologyHttpClient {
|
|||
this.options = JSON.parse(JSON.stringify(options));
|
||||
this.logger = console;
|
||||
this.doLoginMutex = new Mutex();
|
||||
this.apiSerializeMutex = new Mutex();
|
||||
|
||||
if (false) {
|
||||
setInterval(() => {
|
||||
|
|
@ -50,6 +51,7 @@ class SynologyHttpClient {
|
|||
const client = this;
|
||||
const isAuth = data.api == "SYNO.API.Auth" && data.method == "login";
|
||||
let sid;
|
||||
let apiMutexRelease;
|
||||
if (!isAuth) {
|
||||
sid = await this.doLoginMutex.runExclusive(async () => {
|
||||
return await this.login();
|
||||
|
|
@ -58,8 +60,14 @@ class SynologyHttpClient {
|
|||
|
||||
const invoke_options = options;
|
||||
|
||||
if (!isAuth) {
|
||||
if (this.options.serialize) {
|
||||
apiMutexRelease = await this.apiSerializeMutex.acquire();
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (data.api != "SYNO.API.Auth") {
|
||||
if (!isAuth) {
|
||||
data._sid = sid;
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +101,7 @@ class SynologyHttpClient {
|
|||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
request(options, function (error, response, body) {
|
||||
client.log_response(...arguments, options);
|
||||
|
||||
|
|
@ -123,6 +132,11 @@ class SynologyHttpClient {
|
|||
|
||||
resolve(response);
|
||||
});
|
||||
} finally {
|
||||
if (typeof apiMutexRelease == "function") {
|
||||
apiMutexRelease();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -305,6 +305,8 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
);
|
||||
}
|
||||
|
||||
target_id = target.target_id;
|
||||
|
||||
// check if mapping of lun <-> target already exists
|
||||
lun_mapping = target.mapped_luns.find((lun) => {
|
||||
return lun.lun_uuid == lun_uuid;
|
||||
|
|
@ -411,7 +413,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
);
|
||||
break;
|
||||
case "iscsi":
|
||||
//await httpClient.DeleteAllLuns();
|
||||
await httpClient.DeleteAllLuns();
|
||||
|
||||
let iscsiName = driver.buildIscsiName(name);
|
||||
let iqn = driver.options.iscsi.baseiqn + iscsiName;
|
||||
|
|
@ -427,8 +429,12 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
// therefore we continue to search for the lun after delete success call to ensure full deletion
|
||||
await httpClient.DeleteLun(lun_uuid);
|
||||
|
||||
let settleEnabled = driver.options.api.lunDelete.settleEnabled;
|
||||
|
||||
if (settleEnabled) {
|
||||
let currentCheck = 0;
|
||||
let settleMaxRetries = driver.options.api.lunDelete.settleMaxRetries || 6;
|
||||
let settleMaxRetries =
|
||||
driver.options.api.lunDelete.settleMaxRetries || 6;
|
||||
let settleSeconds = driver.options.api.lunDelete.settleSeconds || 5;
|
||||
let waitTimeBetweenChecks = settleSeconds * 1000;
|
||||
|
||||
|
|
@ -448,6 +454,7 @@ class ControllerSynologyDriver extends CsiBaseDriver {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new GrpcError(
|
||||
|
|
|
|||
Loading…
Reference in New Issue