truenas-iscsi: error code has changed on target exists with 25.01

Updates target name existence check to use regex matching
instead of JSON stringify and includes, which is more robust.
This commit is contained in:
Matthew Mckenzie 2025-07-18 13:00:18 +10:00
parent 8193b689ed
commit e642336780
2 changed files with 4 additions and 6 deletions

View File

@ -1128,9 +1128,8 @@ class FreeNASApiDriver extends CsiBaseDriver {
target = null;
if (
response.statusCode == 422 &&
JSON.stringify(response.body).includes(
"Target name already exists"
)
JSON.stringify(response.body)
.match(/Target(.*)name already exists/g)?.length > 0
) {
target = await httpApiClient.findResourceByProperties(
"/iscsi/target",

View File

@ -1205,9 +1205,8 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
target = null;
if (
response.statusCode == 422 &&
JSON.stringify(response.body).includes(
"Target name already exists"
)
JSON.stringify(response.body)
.match(/Target(.*)name already exists/g)?.length > 0
) {
target = await this.findResourceByProperties(
"/iscsi/target",