feat(virtualmachine): Add eviction strategy, grace period, and OS type#159
feat(virtualmachine): Add eviction strategy, grace period, and OS type#159jniedergang wants to merge 5 commits intoharvester:masterfrom
Conversation
81fe719 to
34d1a75
Compare
|
This pull request is now in conflict. Could you fix it @jniedergang? 🙏 |
34d1a75 to
7496769
Compare
|
This pull request is now in conflict. Could you fix it @jniedergang? 🙏 |
7496769 to
8a371e2
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the harvester_virtualmachine Terraform resource to expose additional KubeVirt runtime options (eviction strategy, termination grace period, and OS type annotation) instead of relying on hardcoded defaults, improving configurability and import/read behavior.
Changes:
- Added
eviction_strategy,termination_grace_period_seconds, andos_typefields to the VM schema and constants. - Implemented constructor support to write these fields into the KubeVirt VM spec/annotations.
- Extended importer/state getter plus unit + acceptance tests to cover the new runtime options.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/importer/resource_virtualmachine_importer.go | Import/read support for eviction strategy, termination grace period, and OS type. |
| pkg/importer/resource_virtualmachine_importer_test.go | Unit test coverage for new importer accessors and defaults. |
| pkg/constants/constants_virtualmachine.go | Adds new Terraform field keys and the Harvester OS annotation key constant. |
| internal/provider/virtualmachine/schema_virtualmachine.go | Exposes new runtime options in the Terraform resource schema. |
| internal/provider/virtualmachine/resource_virtualmachine_constructor.go | Writes the new runtime options into the VM spec/annotations during create/update. |
| internal/tests/resource_virtualmachine_test.go | Adds acceptance test for the new runtime options and updates the test config builder. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/provider/virtualmachine/resource_virtualmachine_constructor.go
Outdated
Show resolved
Hide resolved
691a070 to
aad83ea
Compare
ac268a7 to
732cd80
Compare
|
This pull request is now in conflict. Could you fix it @jniedergang? 🙏 |
Make eviction strategy configurable (was hardcoded to LiveMigrateIfPossible). Add termination_grace_period_seconds for graceful shutdown control. Add os_type annotation for KVM guest optimizations. Signed-off-by: Terraform Provider Developer <terraform@harvester.local>
…nds and update docs Add ValidateFunc: validation.IntAtLeast(0) to reject negative values for termination_grace_period_seconds. Add missing field documentation for eviction_strategy, termination_grace_period_seconds, and os_type. Signed-off-by: Terraform Provider Developer <terraform@harvester.local>
- Extract hardcoded defaults into shared constants (DefaultEvictionStrategy, DefaultTerminationGracePeriodSeconds) - Use constants in schema, importer, and tests to avoid drift - Remove Required:true from os_type processor to not override server-provided values when field is unset - Fix test builder to use *int for terminationGracePeriodSeconds, allowing testing of value 0 Signed-off-by: Terraform Provider Developer <terraform@harvester.local>
Fix staticcheck QF1012 lint findings in test builder. Signed-off-by: Terraform Provider Developer <terraform@harvester.local>
381cef6 to
759ba5d
Compare
Prevents InternalValidate error on schedule_backup data source. Signed-off-by: Terraform Provider Developer <terraform@harvester.local>
|
Ran functional tests on Harvester v1.7.1:
Updated test plan in PR description accordingly. |
Summary
termination_grace_period_secondsfor graceful shutdown controlos_typeannotation for KVM guest optimizationsrelated to harvester/harvester#10035
Test plan
go test ./pkg/importer/ -run TestVMRuntimeImporteviction_strategy=None,termination_grace_period_seconds=60— verified viakubectl get vmos_typecomputed field reads correctly (empty when no annotation set)terraform planshows 0 changesterraform destroy— VM cleaned up