-
Notifications
You must be signed in to change notification settings - Fork 7
Check resources using a command #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2 properties are supported, Amount and CheckCommand
b71c9e9 to
7b73e33
Compare
There was a problem hiding this 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
ResourcesAvailableconfiguration to accept either integers or objects withAmount,CheckCommand, andCheckIntervalMillisecondsfields - 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) { |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
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.
| 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 | |
| } |
No description provided.