Skip to content

Conversation

@perk11
Copy link
Owner

@perk11 perk11 commented Oct 28, 2025

No description provided.

@perk11 perk11 force-pushed the resource-check-command branch from b71c9e9 to 7b73e33 Compare October 28, 2025 03:09
@perk11 perk11 requested a review from Copilot October 28, 2025 15:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces the ability to dynamically check resource availability using custom shell commands. The main changes enable resources to be monitored periodically through configurable commands that report availability, rather than relying solely on static configuration values.

Key changes:

  • Added support for resource monitoring via shell commands with configurable check intervals
  • Modified ResourcesAvailable configuration to accept either integers or objects with Amount, CheckCommand, and CheckIntervalMilliseconds fields
  • Introduced a resource monitoring goroutine that periodically executes check commands and updates available resource amounts

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
config.go Added ResourceAvailable struct and custom JSON unmarshaling to support both integer and object formats for resource configuration
config_test.go Added comprehensive tests for the new resource configuration formats and validation
main.go Integrated resource monitoring goroutines and updated resource availability tracking from dynamic state rather than static config
main_test.go Added end-to-end test for resource check command functionality
management_api.go Updated status endpoint to use dynamic resource availability values
management_api_test.go Updated test fixtures to use new resource configuration format
monitor_resources.go Implemented resource monitoring function that executes check commands periodically
util_test.go Added helper function to verify total resources available in test assertions
go.mod Updated testify dependency version
test-configs/jsonc/config.jsonc Added test configuration demonstrating new resource format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"time"
)

func monitorResourceAvailability(resourceName string, checkCommand string, checkInterval time.Duration, resourceManager *ResourceManager) {
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infinite loop will run even when checkCommand is empty. This should be guarded with an early return or conditional to avoid running unnecessary goroutines when no check command is configured.

Suggested change
func monitorResourceAvailability(resourceName string, checkCommand string, checkInterval time.Duration, resourceManager *ResourceManager) {
func monitorResourceAvailability(resourceName string, checkCommand string, checkInterval time.Duration, resourceManager *ResourceManager) {
if strings.TrimSpace(checkCommand) == "" {
log.Printf("[Resource Monitor][%s] No check command configured, skipping resource monitoring.", resourceName)
return
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants