better delete race-condition handling, resize capacity for zvols

This commit is contained in:
Travis Glenn Hansen 2020-11-29 22:59:32 -07:00
parent 8cde1a1979
commit 001301d53e
2 changed files with 136 additions and 104 deletions

View File

@ -1012,7 +1012,11 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
await this.expandVolume(call, datasetName);
return {
capacity_bytes: this.options.zfs.datasetEnableQuotas ? capacity_bytes : 0,
capacity_bytes:
this.options.zfs.datasetEnableQuotas ||
driverZfsResourceType == "volume"
? capacity_bytes
: 0,
node_expansion_required: driverZfsResourceType == "volume" ? true : false,
};
}

View File

@ -1066,12 +1066,9 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
shareId = properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value;
// only remove if the process has not succeeded already
if (zb.helpers.isPropertyValueSet(shareId)) {
// remove nfs share
if (
properties &&
properties[FREENAS_NFS_SHARE_PROPERTY_NAME] &&
properties[FREENAS_NFS_SHARE_PROPERTY_NAME].value != "-"
) {
switch (apiVersion) {
case 1:
case 2:
@ -1113,6 +1110,13 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
} body: ${JSON.stringify(response.body)}`
);
}
// remove property to prevent delete race conditions
// due to id re-use by FreeNAS/TrueNAS
await zb.zfs.inherit(
datasetName,
FREENAS_NFS_SHARE_PROPERTY_NAME
);
}
}
break;
@ -1141,12 +1145,9 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
shareId = properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value;
// only remove if the process has not succeeded already
if (zb.helpers.isPropertyValueSet(shareId)) {
// remove smb share
if (
properties &&
properties[FREENAS_SMB_SHARE_PROPERTY_NAME] &&
properties[FREENAS_SMB_SHARE_PROPERTY_NAME].value != "-"
) {
switch (apiVersion) {
case 1:
case 2:
@ -1191,6 +1192,13 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
} body: ${JSON.stringify(response.body)}`
);
}
// remove property to prevent delete race conditions
// due to id re-use by FreeNAS/TrueNAS
await zb.zfs.inherit(
datasetName,
FREENAS_SMB_SHARE_PROPERTY_NAME
);
}
}
break;
@ -1233,6 +1241,8 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
switch (apiVersion) {
case 1:
case 2:
// only remove if the process has not succeeded already
if (zb.helpers.isPropertyValueSet(targetId)) {
// https://jira.ixsystems.com/browse/NAS-103952
// v1 - /services/iscsi/target/{id}/
@ -1280,6 +1290,13 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
} body: ${JSON.stringify(response.body)}`
);
}
// remove property to prevent delete race conditions
// due to id re-use by FreeNAS/TrueNAS
await zb.zfs.inherit(
datasetName,
FREENAS_ISCSI_TARGET_ID_PROPERTY_NAME
);
} else {
this.ctx.logger.debug(
"not deleting iscsitarget asset as it appears ID %s has been re-used: zfs name - %s, iscsitarget name - %s",
@ -1289,7 +1306,10 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
);
}
}
}
// only remove if the process has not succeeded already
if (zb.helpers.isPropertyValueSet(extentId)) {
// v1 - /services/iscsi/targettoextent/{id}/
// v2 - /iscsi/targetextent/id/{id}
if (apiVersion == 1) {
@ -1332,6 +1352,13 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
} body: ${JSON.stringify(response.body)}`
);
}
// remove property to prevent delete race conditions
// due to id re-use by FreeNAS/TrueNAS
await zb.zfs.inherit(
datasetName,
FREENAS_ISCSI_EXTENT_ID_PROPERTY_NAME
);
} else {
this.ctx.logger.debug(
"not deleting iscsiextent asset as it appears ID %s has been re-used: zfs name - %s, iscsiextent name - %s",
@ -1341,6 +1368,7 @@ class FreeNASDriver extends ControllerZfsSshBaseDriver {
);
}
}
}
break;
default:
throw new GrpcError(