Skip to content
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

Add cpu_pinning and isolate_emulator_thread to vm resource #105

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
crash.log
terraform.tfstate
terraform.tfstate.backup
terraform-provider-harvester
terraform-provider-harvester
kubeconfig_test.yaml
2 changes: 2 additions & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RUN wget --quiet https://github.com/docker/buildx/releases/download/v0.13.1/buil

ENV DAPPER_ENV REPO TAG DRONE_TAG
ENV DAPPER_SOURCE /go/src/github.com/harvester/terraform-provider-harvester
# Use host network for dapper run to allow access to harvester in ACC test
ENV DAPPER_RUN_ARGS "--network host"
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"errors"
"fmt"

"github.com/harvester/harvester/pkg/builder"
harvesterutil "github.com/harvester/harvester/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
kubevirtv1 "kubevirt.io/api/core/v1"

"github.com/harvester/harvester/pkg/builder"
harvesterutil "github.com/harvester/harvester/pkg/util"

"github.com/harvester/terraform-provider-harvester/internal/util"
"github.com/harvester/terraform-provider-harvester/pkg/client"
"github.com/harvester/terraform-provider-harvester/pkg/constants"
Expand Down Expand Up @@ -306,6 +307,20 @@ func (c *Constructor) Setup() util.Processors {
return nil
},
},
{
Field: constants.FieldVirtualMachineCPUPinning,
Parser: func(i interface{}) error {
vmBuilder.VirtualMachine.Spec.Template.Spec.Domain.CPU.DedicatedCPUPlacement = i.(bool)
return nil
},
},
{
Field: constants.FieldVirtualMachineIsolateEmulatorThread,
Parser: func(i interface{}) error {
vmBuilder.VirtualMachine.Spec.Template.Spec.Domain.CPU.IsolateEmulatorThread = i.(bool)
return nil
},
},
}
return append(processors, customProcessors...)
}
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/virtualmachine/schema_virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ please use %s instead of this deprecated field:
Optional: true,
Default: false,
},
constants.FieldVirtualMachineCPUPinning: {
Type: schema.TypeBool,
Description: "To enable VM CPU pinning, ensure that at least one node has the CPU manager enabled",
Optional: true,
Default: false,
},
constants.FieldVirtualMachineIsolateEmulatorThread: {
Type: schema.TypeBool,
Description: "To enable isolate emulator thread, ensure that at least one node has the CPU manager enabled, also VM CPU pinning must be enabled. Note that enable option will allocate an additional dedicated CPU.",
Optional: true,
Default: false,
},
}
util.NamespacedSchemaWrap(s, false)
return s
Expand Down
Loading