2.3 KiB
2.3 KiB
Pool Delete Mountpoint Cleanup
Issue
Ketika pool dihapus, mount point directory tidak dihapus dari sistem. Mount point directory tetap ada di /opt/calypso/data/pool/<pool-name> meskipun pool sudah di-destroy.
Root Cause
Fungsi DeletePool tidak melakukan cleanup untuk mount point directory setelah pool di-destroy.
Solution
Menambahkan kode untuk menghapus mount point directory setelah pool di-destroy.
Changes Made
Updated backend/internal/storage/zfs.go
File: backend/internal/storage/zfs.go (line 518-562)
Menambahkan cleanup untuk mount point directory setelah pool di-destroy:
Before:
// Mark disks as unused
for _, diskPath := range pool.Disks {
// ...
}
// Delete from database
_, err = s.db.ExecContext(ctx, "DELETE FROM zfs_pools WHERE id = $1", poolID)
// ...
After:
// Remove mount point directory (default: /opt/calypso/data/pool/<pool-name>)
mountPoint := fmt.Sprintf("/opt/calypso/data/pool/%s", pool.Name)
if err := os.RemoveAll(mountPoint); err != nil {
s.logger.Warn("Failed to remove mount point directory", "mountpoint", mountPoint, "error", err)
// Don't fail pool deletion if mount point removal fails
} else {
s.logger.Info("Removed mount point directory", "mountpoint", mountPoint)
}
// Mark disks as unused
for _, diskPath := range pool.Disks {
// ...
}
// Delete from database
_, err = s.db.ExecContext(ctx, "DELETE FROM zfs_pools WHERE id = $1", poolID)
// ...
Mount Point Location
Default mount point untuk semua pools adalah:
/opt/calypso/data/pool/<pool-name>/
Behavior
- Pool di-destroy dari ZFS system
- Mount point directory dihapus dengan
os.RemoveAll() - Disks ditandai sebagai unused di database
- Pool dihapus dari database
Error Handling
- Jika mount point removal gagal, hanya log warning
- Pool deletion tetap berhasil meskipun mount point removal gagal
- Ini memastikan bahwa pool deletion tidak gagal hanya karena mount point cleanup
Testing
- Create pool dengan nama "test-pool"
- Verify mount point directory dibuat:
/opt/calypso/data/pool/test-pool/ - Delete pool
- Verify mount point directory dihapus:
ls /opt/calypso/data/pool/test-poolshould fail
Status
✅ FIXED - Mount point directory sekarang dihapus saat pool di-delete
Date
2026-01-09