Commit Graph

455 Commits

Author SHA1 Message Date
rcourtman f9b8037486 fix: resolve install script unbound variables and add update command
Addresses #450, #451, #406

- Initialize all variables at top of script to prevent "unbound variable" errors with set -u
  - BUILD_FROM_SOURCE, SKIP_DOWNLOAD, IN_CONTAINER, IN_DOCKER now set at line 20-27
  - ENABLE_AUTO_UPDATES, FORCE_VERSION, FORCE_CHANNEL, SOURCE_BRANCH also moved to top
  - Removed duplicate assignments from argument parsing section

- Restore /bin/update command creation for ProxmoxVE LXC installations
  - Creates update script that re-runs install.sh for easy updates
  - Allows backend to properly detect ProxmoxVE deployment type
  - Users can now run "update" in LXC console as documented

- Update deployment detection to recognize install.sh in update command
  - Previously only looked for legacy "pulse.sh" reference
  - Now checks for both pulse.sh and install.sh
2025-09-30 16:16:10 +00:00
rcourtman 413ef73953 improve webhook system security and robustness
addresses security vulnerabilities and improves webhook reliability

Changes:
- Add SSRF protection with redirect controls and strict URL validation
- Add response size limits (1MB cap) to prevent memory exhaustion
- Fix race condition in SendTestNotification
- Add per-webhook rate limiting (10 req/min)
- Add Retry-After header support for proper backoff
- Extract magic numbers to configurable constants
- Block localhost, link-local, and cloud metadata endpoints
- Add secure HTTP client with redirect validation
- Remove duplicate function definitions
- Clean up unused code

Security improvements:
- Prevents SSRF attacks via redirect chains
- Protects against DoS via large responses
- Rate limits prevent webhook flooding
- Thread-safe webhook operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 15:57:28 +00:00
rcourtman 552173b262 fix: improve alert system robustness and security
Addresses multiple issues identified during comprehensive alert system audit:

1. Fix ZFS device loop lock issue
   - Moved lock acquisition outside loop in checkZFSPoolHealth
   - Changed clearAlert to clearAlertNoLock when lock already held
   - Prevents multiple lock acquisitions in same iteration

2. Add alert deduplication on restore
   - Prevents duplicate alerts after service restart
   - Tracks seen alert IDs during LoadActiveAlerts
   - Logs warnings for any duplicates found

3. Add API input validation
   - validateAlertID function prevents DOS attacks
   - Limit alert ID length to 500 characters
   - Whitelist allowed characters (alphanumeric, -, _, :, /, .)
   - Cap history limit parameter at 10,000 records
   - Applied validation to acknowledge, unacknowledge, and clear endpoints

4. Add panic recovery to goroutines
   - All SaveActiveAlerts goroutines now have defer/recover
   - Cleanup goroutines protected from panics
   - Contextual error logging for each goroutine type

5. Document lock ordering
   - Added comprehensive documentation for Manager mutexes
   - Explains m.mu and resolvedMutex relationship
   - Clarifies acquisition rules to prevent deadlocks
   - Inline comments for resolvedMutex field

These fixes improve stability, security, data integrity, and maintainability
of the alert system without breaking API compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 15:35:39 +00:00
rcourtman 1d987efcc9 docs: fix VM disk monitoring documentation and remove false token limitation claims
Corrected widespread misinformation claiming API tokens cannot access guest agent data on Proxmox 9.

Changes:
- Rewrote VM_DISK_MONITORING.md with accurate technical explanation
- Deleted VM_DISK_STATS_TROUBLESHOOTING.md (contained false information)
- Updated FAQ.md with correct quick reference and troubleshooting link
- Added comprehensive VM disk troubleshooting section to TROUBLESHOOTING.md
- Fixed README.md troubleshooting reference
- Updated frontend tooltip to show accurate permission requirements
- Corrected backend log messages to remove "known limitation" language
- Updated test-vm-disk.sh diagnostic script with accurate guidance

Key corrections:
- API tokens work fine for guest agent queries on both PVE 8 and 9
- Proxmox API returning disk=0 is normal behavior, not a bug
- Both tokens and passwords work equally well
- Only requirements: guest agent installed + proper permissions
- Permission issues are config problems, not authentication method limitations

Documentation now provides clear user journey: FAQ → Troubleshooting → Full Guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 15:14:23 +00:00
Pulse Monitor e0e5528fe3 feat: add demo mode with read-only protection
Adds DEMO_MODE environment variable that blocks all write operations
while allowing full read/view functionality. Includes banner notification
in UI when demo mode is active.

Addresses need for safe public demo instances.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 14:46:20 +00:00
Pulse Monitor 3331e1f2ab feat: add real-time streaming discovery and improve dev/mock mode switching
- Added streaming discovery that shows servers as they're found
- Backend sends WebSocket updates for each discovered server
- Frontend displays servers immediately without waiting for full scan
- Created sync-production-config.sh to preserve nodes when switching modes
- Updated toggle-mock.sh to sync config when disabling mock mode
- Dev environment now maintains separate config that syncs from production
- Enabled discovery service in dev environment by default

addresses real-time discovery UX and mock/production mode configuration persistence
2025-09-30 13:13:32 +00:00
rcourtman 5470d2350b Add runtime mock toggles and auth-safe dev assets 2025-09-30 10:02:26 +00:00
rcourtman 013431a139 chore: tidy repo formatting and linting 2025-09-29 20:19:18 +00:00
rcourtman e72d12d86e Refine security settings UI and credential rotation flow 2025-09-29 17:42:10 +00:00
rcourtman 8910e1e379 Fix installer defaults, auth fallbacks, alert persistence, and docs helper 2025-09-29 16:36:33 +00:00
rcourtman 3d78c0a9fa Improve security settings UX and fix alerts typing 2025-09-29 15:52:03 +00:00
rcourtman 9852ef9047 Align dev ports and improve auto-register UX 2025-09-29 15:05:59 +00:00
rcourtman 645c793f82 feat: add OIDC single sign-on 2025-09-29 10:22:27 +00:00
rcourtman 6f4771ae2d feat: unify styling and improve cluster detection 2025-09-28 18:46:52 +00:00
Pulse Monitor 9331ef53ae Revert "fix: only use cluster/resources when IsCluster is true (addresses #448)"
This reverts commit 4a9912f410.
2025-09-11 20:21:08 +00:00
Pulse Monitor 6e8e2d14f5 fix: only use cluster/resources when IsCluster is true (addresses #448)
The aggressive use of cluster/resources was breaking storage collection
for setups with multiple standalone nodes or improperly clustered nodes.
Now only uses cluster/resources when explicitly configured as a cluster,
falling back to traditional node-by-node polling otherwise.

This should fix the missing storage issue where one node's storage
wasn't showing after upgrading to rc5.
2025-09-11 20:18:18 +00:00
Pulse Monitor 1412105f99 fix: preserve storage when node returns empty result but has existing data (addresses #448)
The issue was that when a node was successfully polled but returned empty storage
(e.g., due to API permissions), it was still marked as 'successfully polled'.
This prevented the preservation logic from keeping existing storage data.

Now if a node returns empty storage but we have existing storage for that node,
we don't mark it as polled, allowing the preservation logic to keep the data.

This should fix the issue where storage disappears from one node in #448.
2025-09-11 16:00:25 +00:00
Pulse Monitor d514458fbb fix: improve storage collection resilience when nodes timeout (addresses #448)
- Send error result to channel when storage query times out so preservation logic works
- Ensures storage data is preserved for nodes that experience timeouts
- Fixes issue where storage/backups would disappear when a node times out
2025-09-11 15:51:37 +00:00
Pulse Monitor 47c12a2897 test: create test version for issue #448 2025-09-11 15:01:23 +00:00
Pulse Monitor fea7cbd5d3 fix: preserve storage data when node times out (addresses #448)
When a node's storage query times out, don't return empty storage which would wipe out existing data. Instead, skip the node entirely so the preservation logic can maintain the existing storage information.
2025-09-11 14:55:50 +00:00
Pulse Monitor d1dc451f61 chore: bump version to v4.15.0-rc.7 2025-09-11 14:19:58 +00:00
Pulse Monitor a7ac3a50da chore: bump version to v4.15.0-rc.6 2025-09-11 14:02:05 +00:00
Pulse Monitor 496ab7acdb simplify: remove complex override matching logic in favor of consistent ID generation
Removed the flexible ID matching code that was added for backward compatibility. Since we've fixed the frontend to generate IDs consistently with the backend, we don't need the complexity of trying multiple ID formats.

This keeps the codebase simpler and more maintainable.
2025-09-11 13:34:03 +00:00
Pulse Monitor 9d40e56223 fix: improve alert override ID matching to handle various frontend ID formats (addresses #441)
The frontend can save alert overrides with different ID formats depending on how the cluster is configured. This fix makes the backend more flexible in matching these overrides by:

1. Trying the exact guest ID first
2. Checking for partial matches that end with -node-vmid
3. Trying alternative ID formats like node-vmid and instance-node-vmid

This ensures custom alert thresholds work correctly regardless of the cluster name format used when saving overrides.
2025-09-11 13:25:51 +00:00
Pulse Monitor 67676b291c improve: use efficient cluster/resources endpoint for all nodes
- Always try cluster/resources endpoint first (works on standalone nodes too)
- Only fall back to traditional polling for very old Proxmox versions
- Confirmed working on standalone nodes like pimox
- Significantly reduces API calls and improves performance
- Addresses efficiency concerns from #447
2025-09-11 12:57:32 +00:00
Pulse Monitor e386a83778 cleanup: remove legacy POLLING_INTERVAL env variable (addresses #447)
PVE polling is hardcoded to 10s since Proxmox cluster/resources endpoint only updates every 10s internally. Setting faster polling intervals was wasteful and provided no benefit.

Removed:
- POLLING_INTERVAL env variable and all references
- pollingInterval from config structs and API responses
- UI settings for polling interval (already removed)
- Dynamic polling interval updates via SIGHUP
- Legacy persistence code for saving polling settings

The monitoring loop now uses a hardcoded 10s interval matching Proxmox's update frequency.
2025-09-11 12:33:44 +00:00
Pulse Monitor bd0c817056 fix: handle trailing slashes in node URLs (addresses #428)
Strip trailing slashes and paths from URLs before parsing host:port
to prevent "invalid port number" errors when users add nodes with
URLs like https://192.168.xxx.xxx:8006/
2025-09-11 12:27:24 +00:00
Pulse Monitor 9646f8ed59 fix: correct mock generator guest ID format to match alert system (addresses #441)
Mock VMs and containers were using 'node:qemu/vmid' format but the alert
system expects 'instance-node-vmid' format. This caused custom thresholds
to be ignored for mock guests.
2025-09-11 12:05:55 +00:00
Pulse Monitor 9486e8679d improve: enhance VM disk usage detection for Windows guests (addresses #416)
- Add debug logging to guest agent filesystem API responses
- Better handle Windows drive mountpoints (C:\, D:\, etc.)
- Improve empty filesystem list detection and logging
- Add specific handling for Windows filesystems that may report differently

This should help diagnose why some VMs with guest agents installed still show 0% or missing disk usage, particularly on Windows systems.
2025-09-11 08:47:23 +00:00
Pulse Monitor 1a147bec86 revert: version back to 4.15.0-rc.4 2025-09-11 07:36:48 +00:00
Pulse Monitor b4c7240865 chore: bump version to v4.15.0-rc.5 2025-09-11 07:33:12 +00:00
Pulse Monitor d4f87a6230 feat: add physical disk diagnostics to help troubleshoot missing disks (addresses #429)
- Add comprehensive disk detection diagnostics to /api/diagnostics
- Shows which nodes return disks and which don't
- Provides specific error messages and API responses
- Includes targeted recommendations based on failure type
- Helps users provide better debugging info when reporting issues
2025-09-11 07:28:15 +00:00
Pulse Monitor 23b2377c77 improve: enhance disk polling error logging to help diagnose missing disks (addresses #429)
- Add specific warning for permission errors (401/403)
- Add info message for nodes without disk monitoring support
- Elevate error logging from debug to warn level for visibility
- Helps users understand why disks might not appear for certain nodes
2025-09-11 07:20:17 +00:00
Pulse Monitor 2c512a96e3 chore: bump version to v4.15.0-rc.4 2025-09-10 21:38:46 +00:00
Pulse Monitor a9714e62f6 fix: improve WebSocket connection reliability in dev environment
- Increase WebSocket buffer sizes from 64KB to 4MB to handle large mock data
- Add robust reconnection logic with exponential backoff
- Implement heartbeat mechanism to detect stale connections faster
- Add manual reconnect button in UI when connection fails
- Fix unused variable warnings in monitor code
- Add debug logging to trace WebSocket state initialization

This resolves the issue where the frontend would hang after code changes
during hot-reload, especially when using mock mode with many nodes.
2025-09-10 21:35:20 +00:00
Pulse Monitor 94943ea847 fix: preserve storage/backup data for temporarily offline nodes (addresses #429)
- Storage polling now preserves existing data when nodes are temporarily offline
- Backup polling preserves existing backups for unpolled nodes
- Prevents storage and backups from disappearing when nodes have connectivity issues
- Similar to the physical disk preservation fix
2025-09-10 20:59:46 +00:00
Pulse Monitor 9d905a356c fix: preserve physical disk data for temporarily offline nodes (addresses #429)
When a node is temporarily offline or has connectivity issues, preserve its last known physical disk data instead of removing it from the table. This prevents nodes from disappearing from the Physical Disks table when they have transient connection problems.
2025-09-10 20:44:51 +00:00
Pulse Monitor 2dbd9c4e36 feat: implement per-resource-type alert delays
- VMs/Containers default to 10 seconds
- Nodes default to 15 seconds
- Storage defaults to 30 seconds
- PBS servers default to 30 seconds

This allows more appropriate delays for different resource types instead of a single global delay that doesn't fit all use cases. Storage and PBS can have longer delays since they're less critical and more prone to transient spikes during operations.
2025-09-10 19:45:42 +00:00
Pulse Monitor 6c125c23dc fix: remove incorrect 100% threshold disabling logic
The 100% threshold disabling feature was incorrectly implemented and doesn't
make logical sense - metrics can legitimately reach 100% (CPU, memory, storage)
and those are critical conditions that should trigger alerts.

The correct way to disable specific alerts is already implemented:
- Set threshold to 0 or negative to disable a metric type globally
- Use per-resource overrides to disable specific metrics for specific resources
- Example: Overrides[guest-id].Memory = {Trigger: 0} disables memory alerts for that guest

This removes the confusing behavior where 100% thresholds would disable alerts
instead of alerting on actual 100% usage conditions.
2025-09-10 18:38:31 +00:00
Pulse Monitor 519119989a fix: storage threshold overrides not being applied (addresses #441, #434)
Two critical issues fixed:
1. Storage threshold overrides were being loaded but never applied - the code
   always used the default threshold instead of checking for overrides
2. Setting a threshold to 100% now properly disables alerts for that metric,
   allowing users to suppress specific alerts they don't want

This fixes both the storage threshold persistence issue and the inability
to disable alerts by setting thresholds to 100%.
2025-09-10 17:20:01 +00:00
Pulse Monitor b270ef7501 fix: improve PBS alert threshold persistence when updating nodes (addresses #440)
The issue was that PBS monitoring uses name-based IDs (pbs-<name>) while
the config system uses index-based IDs (pbs-0, pbs-1). When updating PBS
node configuration, the alert overrides were already being preserved but
the ID mismatch wasn't properly documented. Added explicit logging to
track PBS override preservation using the correct monitoring ID.
2025-09-10 17:11:53 +00:00
Pulse Monitor ceb9939295 fix: ensure cluster endpoints include port number (addresses #428)
When detecting Proxmox cluster nodes, the Host field was being set to just the node name without a port. This caused validation to fail with "invalid Port number" error when qdevices were running.

Now cluster endpoints properly include the port (8006) in the Host field, allowing clusters with qdevices to be added successfully.
2025-09-10 17:01:11 +00:00
Pulse Monitor 311f23cf4e chore: bump version to v4.15.0-rc.3 2025-09-10 16:08:01 +00:00
Pulse Monitor 86ab611961 perf: fix performance issues with large mock datasets (800+ guests)
- Limit alert checking to 50 guests per cycle to prevent blocking
- Remove unnecessary state broadcast when alerts are resolved
- Fix deadlock in GetActiveAlerts by releasing lock quickly
- Enable handling of 800+ mock guests with sub-10ms response times

This allows Pulse to handle large-scale deployments efficiently for testing and production use.
2025-09-10 16:04:35 +00:00
Pulse Monitor 0aeeb3da0d fix: resolve alert acknowledgment timeout issue (addresses #438)
The alert acknowledgment endpoints were hanging because GetState() was called
synchronously to broadcast updates via WebSocket, which could take significant
time with many nodes/guests. This caused the HTTP response to timeout, showing
an error to users even though the alert was successfully acknowledged.

Fixed by:
- Sending HTTP response immediately after acknowledging the alert
- Moving WebSocket broadcast to a goroutine to avoid blocking
- Applied fix to all alert endpoints (acknowledge, unacknowledge, clear, bulk ops)

This resolves the issue where users saw 'Failed to acknowledge alert' errors
but the alert was actually acknowledged (disappeared on refresh).
2025-09-10 15:49:12 +00:00
Pulse Monitor ce6a76a0f9 fix: preserve PBS alert thresholds when updating node configuration (addresses #440)
When updating PBS nodes through the node configuration UI, alert thresholds
were being reset to defaults. This was because alert overrides are stored
separately from node configuration and weren't being preserved during node updates.

The fix ensures that when a node is updated, the alert configuration (including
any custom threshold overrides) is reloaded and preserved. This applies to both
PBS and PVE nodes to ensure consistent behavior.
2025-09-10 15:12:43 +00:00
Pulse Monitor e731f954b3 fix: resolve PBS API permission errors and missing parameters (addresses #436)
- handle PBS node status endpoint permission errors gracefully (returns nil instead of error for 403s)
- add required cf and timeframe parameters to RRD endpoint calls
- properly handle nil nodeStatus returns in monitor.go

these API calls now fail silently as PBS API tokens often lack the required permissions for these endpoints, which is expected behavior
2025-09-10 14:51:52 +00:00
Pulse Monitor 670bf4665d fix: improve cluster detection reliability on first add (addresses #437)
- Add retry logic with delays to detectPVECluster function to handle API permission propagation
- Periodically re-check standalone nodes to detect if they're actually part of a cluster
- Increase timeout from 3 to 5 seconds for cluster detection attempts
- Skip retries for definitively standalone nodes (501 not implemented errors)

This addresses the issue where adding a PVE cluster doesn't detect it properly on first attempt,
requiring deletion and re-adding to work correctly. The retry mechanism gives time for
API permissions to fully propagate in Proxmox.
2025-09-10 14:39:01 +00:00
Pulse Monitor 25ed6172a0 refactor: improve service name detection compatibility (addresses #430)
- Use centralized detectServiceName() function instead of duplicate logic
- Automatically detect whether system uses 'pulse' or 'pulse-backend' service
- Improves compatibility between official and community installer scripts
- Reduces confusion when users mix installation methods
2025-09-10 12:33:20 +00:00
Pulse Monitor 6f840834f1 feat: improve memory reporting accuracy using available memory (addresses #435)
- Calculate memory as (Total - Available) instead of raw Used value
- Excludes buffer/cache memory that Linux can reclaim when needed
- Prevents false alerts from Linux cache usage
- Falls back to traditional calculation on older Proxmox versions
- VMs already use FreeMem from guest agent when available
- Memory usage will appear lower but more accurate (e.g., 56% instead of 84%)
- Users may need to adjust alert thresholds accordingly
2025-09-10 10:17:07 +00:00