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 option #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brandboat
Copy link
Member

@brandboat brandboat commented Oct 21, 2024

related to harvester/harvester#6551, as title, add cpu_pinning and isolate_emulator_thread option.

Test Plan

Prerequisite

  • rancher 2.9.1 (docker image)
  • harvester single node (v1.4.0-rc, would be better to have 12CPUs as we will create VM with 8cpus in test plan)
    • > 8 CPUs and > 12GB mem
    • please enable cpu manager

Test steps

  1. Build docker-machine-driver-harvester with this patch(i.e. PR)
  2. Import harvester cluster to rancher (i.e. cluster-registration-url)
  3. Go to rancher UI, deactivate harvester node driver
  4. Copy the binary built in step 1. to path /opt/drivers/management-state/bin in rancher container
    docker cp docker-machine-driver-harvester <rancher_container_id>:/opt/drivers/management-state/bin/docker-machine-driver-harvester
  5. In rancher container, delete harvester dynamic schema
    kubectl delete dynamicschemas.management.cattle.io/harvesterconfig
  6. Go to rancher UI, activate harvester node driver
  7. In rancher container, apply the following yaml files to deploy rke2 guest cluster to harvester. (make sure you fill in all fields start with <YOUR_... in the yaml examples.)
    • harvesterconfig.yaml
     apiVersion: rke-machine-config.cattle.io/v1
     cpuCount: "8"
     cpuPinning: true
     diskInfo: '{"disks":[{"imageName":"default/<YOUR_IMAGE_UNDER_DEFAULT_NS>","bootOrder":1,"size":40}]}'
     isolateEmulatorThread: true
     kind: HarvesterConfig
     memorySize: "12"
     metadata:
       name: test
       namespace: fleet-default
     networkInfo: '{"interfaces":[{"networkName":"default/<YOUR_VM_NERWORK_UNDER_DEFAULT_NS>","macAddress":""}]}'
     sshPort: "22"
     sshUser: ubuntu
     userData: I2Nsb3VkLWNvbmZpZwpwYWNrYWdlX3VwZGF0ZTogdHJ1ZQpwYWNrYWdlczoKICAtIHFlbXUtZ3Vlc3QtYWdlbnQKcnVuY21kOgogIC0gLSBzeXN0ZW1jdGwKICAgIC0gZW5hYmxlCiAgICAtICctLW5vdycKICAgIC0gcWVtdS1ndWVzdC1hZ2VudC5zZXJ2aWNlCg==
     vmNamespace: default
    • cluster.yaml
    apiVersion: provisioning.cattle.io/v1
     kind: Cluster
     metadata:
       name: foobar
       namespace: fleet-default
     spec:
       cloudCredentialSecretName: cattle-global-data:<YOUR_CLOUD_CREDENTIAL_SECRET_NAME>
       kubernetesVersion: v1.30.5+rke2r1
       rkeConfig:
         etcd:
           disableSnapshots: false
           snapshotRetention: 5
           snapshotScheduleCron: 0 */5 * * *
         machineGlobalConfig:
           cni: calico
           disable-kube-proxy: false
           etcd-expose-metrics: false
         machinePools:
           - name: pool1
             etcdRole: true
             controlPlaneRole: true
             workerRole: true
             quantity: 1
             unhealthyNodeTimeout: 0m
             machineConfigRef:
               kind: HarvesterConfig
               name: test
             drainBeforeDelete: true
             labels: {}
         machineSelectorConfig:
           - config:
               cloud-provider-name: harvester
               protect-kernel-defaults: false
         upgradeStrategy:
           controlPlaneConcurrency: '1'
           controlPlaneDrainOptions:
             deleteEmptyDirData: true
             disableEviction: false
             enabled: false
             force: false
             gracePeriod: -1
             ignoreDaemonSets: true
             skipWaitForDeleteTimeoutSeconds: 0
             timeout: 120
           workerConcurrency: '1'
           workerDrainOptions:
             deleteEmptyDirData: true
             disableEviction: false
             enabled: false
             force: false
             gracePeriod: -1
             ignoreDaemonSets: true
             skipWaitForDeleteTimeoutSeconds: 0
             timeout: 120
  8. Go to harvester UI, navigate to Virtual Machines page, check the vm have the following attributes
     dedicatedCpuPlacement: true
     isolateEmulatorThread: true
    image

@brandboat brandboat marked this pull request as ready for review November 5, 2024 06:31
@brandboat brandboat added the enhancement New feature or request label Nov 5, 2024
Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@bk201
Copy link
Member

bk201 commented Nov 7, 2024

@FrankYang0529 do we need to ensure there is no such an upgrade path that upgrading from a Rancher with the fields to a Rancher without the new fields?

@FrankYang0529
Copy link
Member

@FrankYang0529 do we need to ensure there is no such an upgrade path that upgrading from a Rancher with the fields to a Rancher without the new fields?

Yes, we need. If we only add it to latest rancher v2.9.x version, I think there is no way to downgrade to old rancher version.

Copy link
Contributor

@ibrokethecloud ibrokethecloud left a comment

Choose a reason for hiding this comment

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

the changes look good, may be we just need to fine tune the usage message on the two flags.

mcnflag.BoolFlag{
EnvVar: "HARVESTER_CPU_PINNING",
Name: "harvester-cpu-pinning",
Usage: "enable vm cpu pinning, make sure the the harvester cluster enable cpu manager in at least one node",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Usage: "enable vm cpu pinning, make sure the the harvester cluster enable cpu manager in at least one node",
Usage: "enable vm cpu pinning, please ensure the harvester cluster has cpu manager enabled in at least one node",

mcnflag.BoolFlag{
EnvVar: "HARVESTER_ISOLATE_EMULATOR_THREAD",
Name: "harvester-isolate-emulator-thread",
Usage: "enable vm isolatate emulator thread, note that enabling this feature will acquire one more cpu",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Usage: "enable vm isolatate emulator thread, note that enabling this feature will acquire one more cpu",
Usage: "enable vm isolatated emulator thread",

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comments! I've addressed everything in the latest commit.

Copy link
Contributor

@ibrokethecloud ibrokethecloud left a comment

Choose a reason for hiding this comment

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

lgtm. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants