make target delete more robust during in use scenarios
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
e0657190ed
commit
196e2f6744
|
|
@ -4,6 +4,10 @@ set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
export PATH="/usr/local/lib/nodejs/bin:${PATH}"
|
export PATH="/usr/local/lib/nodejs/bin:${PATH}"
|
||||||
|
|
||||||
|
node --version
|
||||||
|
npm --version
|
||||||
|
|
||||||
# install deps
|
# install deps
|
||||||
npm i
|
npm i
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
const _ = require("lodash");
|
||||||
const { GrpcError, grpc } = require("../../utils/grpc");
|
const { GrpcError, grpc } = require("../../utils/grpc");
|
||||||
const { CsiBaseDriver } = require("../index");
|
const { CsiBaseDriver } = require("../index");
|
||||||
const HttpClient = require("./http").Client;
|
const HttpClient = require("./http").Client;
|
||||||
|
|
@ -1539,7 +1540,25 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteAsset) {
|
if (deleteAsset) {
|
||||||
|
let retries = 0;
|
||||||
|
let maxRetries = 5;
|
||||||
|
let retryWait = 1000;
|
||||||
response = await httpClient.delete(endpoint);
|
response = await httpClient.delete(endpoint);
|
||||||
|
|
||||||
|
// sometimes after an initiator has detached it takes a moment for TrueNAS to settle
|
||||||
|
// code: 422 body: {\"message\":\"Target csi-ci-55877e95sanity-node-expand-volume-e54f81fa-cd38e798 is in use.\",\"errno\":14}
|
||||||
|
while (
|
||||||
|
response.statusCode == 422 &&
|
||||||
|
retries < maxRetries &&
|
||||||
|
_.get(response, "body.message").includes("Target") &&
|
||||||
|
_.get(response, "body.message").includes("is in use") &&
|
||||||
|
_.get(response, "body.errno") == 14
|
||||||
|
) {
|
||||||
|
retries++;
|
||||||
|
await sleep(retryWait);
|
||||||
|
response = await httpClient.delete(endpoint);
|
||||||
|
}
|
||||||
|
|
||||||
if (![200, 204, 404].includes(response.statusCode)) {
|
if (![200, 204, 404].includes(response.statusCode)) {
|
||||||
throw new GrpcError(
|
throw new GrpcError(
|
||||||
grpc.status.UNKNOWN,
|
grpc.status.UNKNOWN,
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,10 @@ class ISCSI {
|
||||||
"-o",
|
"-o",
|
||||||
"new",
|
"new",
|
||||||
]);
|
]);
|
||||||
|
// create DB entry
|
||||||
await iscsi.exec(options.paths.iscsiadm, args);
|
await iscsi.exec(options.paths.iscsiadm, args);
|
||||||
|
|
||||||
|
// update attributes 1 by 1
|
||||||
for (let attribute in attributes) {
|
for (let attribute in attributes) {
|
||||||
let args = [];
|
let args = [];
|
||||||
args = args.concat([
|
args = args.concat([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue