feat(kubevirt): add run policy support to VM lifecycle management#1012
Open
awels wants to merge 1 commit into
Open
feat(kubevirt): add run policy support to VM lifecycle management#1012awels wants to merge 1 commit into
awels wants to merge 1 commit into
Conversation
Author
|
/cc @lyarwood |
Contributor
|
/lgtm |
Closed
Collaborator
|
/run-mcpchecker kubevirt |
lyarwood
reviewed
Apr 16, 2026
|
|
||
| // Parse optional run_policy parameter (defaults to HighAvailability) | ||
| runPolicyStr := api.OptionalString(params, "run_policy", string(kubevirt.RunPolicyHighAvailability)) | ||
| runPolicy := kubevirt.RunPolicy(runPolicyStr) |
Contributor
There was a problem hiding this comment.
The run_policy value is cast directly to RunPolicy without server-side validation. getRunStrategyFromRunPolicy silently defaults invalid values to Always, which masks errors. Consider adding explicit validation:
if !kubevirt.IsValidRunPolicy(runPolicy) {
return api.NewToolCallResult("", fmt.Errorf("invalid run_policy %q: must be one of HighAvailability, RestartOnFailure, Once", runPolicyStr)), nil
}| } | ||
|
|
||
| // Parse optional run_policy parameter (defaults to HighAvailability) | ||
| runPolicyStr := api.OptionalString(params, "run_policy", string(kubevirt.RunPolicyHighAvailability)) |
Contributor
There was a problem hiding this comment.
nit: run_policy is parsed for all actions but only used by start. Consider moving this inside the ActionStart case to avoid confusion.
c55d4c1 to
640436a
Compare
lyarwood
approved these changes
May 7, 2026
Collaborator
|
/run-mcpchecker kubevirt |
Collaborator
|
@awels can you fix the merge conflict on the readme? |
Author
|
Sure give me a bit to rebase. |
Adds a new run_policy parameter to the vm_lifecycle tool that allows users to control the VM's runStrategy when starting/restarting a virtual machine. The parameter supports three policies: - HighAvailability: VM runs continuously (sets runStrategy to Always) - RestartOnFailure: VM restarts on failure (sets runStrategy to RerunOnFailure) - Once: VM runs once and stops after completion (sets runStrategy to Once) The run_policy parameter is optional and defaults to HighAvailability to maintain backward compatibility with existing usage. Changes include: - Updated StartVM function to accept RunPolicy parameter - Updated RestartVM function to accept RunPolicy parameter - StopVM ignores run_policy parameter - Added unit tests covering all run policy combinations - Added integration tests for vm_lifecycle tool - Updated tool schema with enum values and documentation - Auto-generated README.md updates Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Alexander Wels <awels@redhat.com>
640436a to
323bb8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new run_policy parameter to the vm_lifecycle tool that allows users to control the VM's runStrategy when starting a virtual machine.
The parameter supports three policies:
The run_policy parameter is optional and defaults to HighAvailability to maintain backward compatibility with existing usage.
Changes include: