replace tape library body layout

This commit is contained in:
Warp Agent
2025-12-26 16:36:47 +00:00
parent 419fcb7625
commit 5e63ebc9fe
11 changed files with 1523 additions and 180 deletions

View File

@@ -391,7 +391,8 @@ func (s *ZFSService) ListPools(ctx context.Context) ([]*ZFSPool, error) {
&pool.CreatedAt, &pool.UpdatedAt, &pool.CreatedBy,
)
if err != nil {
return nil, fmt.Errorf("failed to scan pool: %w", err)
s.logger.Error("Failed to scan pool row", "error", err)
continue // Skip this pool instead of failing entire query
}
if description.Valid {
pool.Description = description.String
@@ -407,8 +408,14 @@ func (s *ZFSService) ListPools(ctx context.Context) ([]*ZFSPool, error) {
}
pools = append(pools, &pool)
s.logger.Debug("Added pool to list", "pool_id", pool.ID, "name", pool.Name)
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("error iterating pool rows: %w", err)
}
s.logger.Debug("Listed ZFS pools", "count", len(pools))
return pools, nil
}
@@ -460,11 +467,22 @@ func (s *ZFSService) DeletePool(ctx context.Context, poolID string) error {
return err
}
// Destroy ZFS pool
cmd := exec.CommandContext(ctx, "zpool", "destroy", pool.Name)
// Destroy ZFS pool with -f flag to force destroy (works for both empty and non-empty pools)
// The -f flag is needed to destroy pools even if they have datasets or are in use
s.logger.Info("Destroying ZFS pool", "pool", pool.Name)
cmd := exec.CommandContext(ctx, "zpool", "destroy", "-f", pool.Name)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to destroy ZFS pool: %s: %w", string(output), err)
errorMsg := string(output)
// Check if pool doesn't exist (might have been destroyed already)
if strings.Contains(errorMsg, "no such pool") || strings.Contains(errorMsg, "cannot open") {
s.logger.Warn("Pool does not exist in ZFS, continuing with database cleanup", "pool", pool.Name)
// Continue with database cleanup even if pool doesn't exist
} else {
return fmt.Errorf("failed to destroy ZFS pool: %s: %w", errorMsg, err)
}
} else {
s.logger.Info("ZFS pool destroyed successfully", "pool", pool.Name)
}
// Mark disks as unused