freenas-proxmox/perl5/PVE
Kevin Adams af737128d2 Fix dangling extent on failed LUN creation (issue #214)
Two problems in run_create_lu:
1. If freenas_iscsi_create_extent returned undef, the next line accessed
   $extent->{'id'} unconditionally, causing a crash rather than a clean error.
2. If freenas_iscsi_create_target_to_extent failed after a successful extent
   creation, the code just died with "Unable to create lun", leaving the
   newly created extent orphaned on TrueNAS with no target association.
   Subsequent delete_lu calls could not find or clean up this extent because
   it was never in the LUN list, requiring manual TrueNAS cleanup.

Fix: check extent creation result before dereferencing; on target-to-extent
failure, call freenas_iscsi_remove_extent to roll back the extent before
dying. The rollback is best-effort (failure is logged but not re-thrown)
so a secondary API error does not mask the primary failure message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 23:23:20 -04:00
..
Storage Fix dangling extent on failed LUN creation (issue #214) 2026-05-15 23:23:20 -04:00