Skip to content

Commit

Permalink
Incorporate feedback from reviewers
Browse files Browse the repository at this point in the history
Signed-off-by: Stu Gott <[email protected]>
  • Loading branch information
stu-gott committed Apr 26, 2018
1 parent 227fadd commit ef9e3cb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
12 changes: 6 additions & 6 deletions docs/software-emulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ approach is problematic. For instance, running KubeVirt on a cluster where the
nodes do not support hardware emulation.

If `allowEmulation` is enabled, hardware emulation via `/dev/kvm` will still be
attempted first, and only if the device is unavailable will software emulation
be used.
attempted first. Software emulation will only be used if the device is
unavailable.

# Configuration

Expand All @@ -16,16 +16,16 @@ activated using a ConfigMap in the `kube-system` namespace. It can be enabled
with the following command:

```bash
cluster/kubectl.sh --namespace kube-system create configmap virt-controller \
cluster/kubectl.sh --namespace kube-system create configmap kubevirt-config \
--from-literal debug.allowEmulation=true
```

If the `kube-system/virt-controller` ConfigMap already exists, the above entry
If the `kube-system/kubevirt-config` ConfigMap already exists, the above entry
can be added using:


```bash
cluster/kubectl.sh --namespace kube-system edit configmap virt-controller
cluster/kubectl.sh --namespace kube-system edit configmap kubevirt-config
```

In this case, add the `debug.allowEmulation: "true"` setting to `data`:
Expand All @@ -34,7 +34,7 @@ In this case, add the `debug.allowEmulation: "true"` setting to `data`:
apiVersion: v1
kind: ConfigMap
metadata:
name: virt-controller
name: kubevirt-config
namespace: kube-system
data:
debug.allowEmulation: "true"
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-controller/services/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
registrydisk "kubevirt.io/kubevirt/pkg/registry-disk"
)

const configMapName = "kube-system/virt-controller"
const configMapName = "kube-system/kubevirt-config"
const allowEmulationKey = "debug.allowEmulation"

type TemplateService interface {
Expand Down
14 changes: 10 additions & 4 deletions pkg/virt-controller/services/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,11 @@ var _ = Describe("Template", func() {

It("Should return false if configmap doesn't have allowEmulation set", func() {
cfgMap := kubev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: "kube-system/virt-controller"},
Data: map[string]string{},
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "kubevirt-config",
},
Data: map[string]string{},
}
cmListWatch = MakeFakeConfigMapWatcher([]kubev1.ConfigMap{cfgMap})
cmInformer = cache.NewSharedIndexInformer(cmListWatch, &v1.VirtualMachine{}, time.Second, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
Expand All @@ -368,8 +371,11 @@ var _ = Describe("Template", func() {

It("Should return true if allowEmulation = true", func() {
cfgMap := kubev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{Name: "kube-system/virt-controller"},
Data: map[string]string{"debug.allowEmulation": "true"},
ObjectMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "kubevirt-config",
},
Data: map[string]string{"debug.allowEmulation": "true"},
}
cmListWatch = MakeFakeConfigMapWatcher([]kubev1.ConfigMap{cfgMap})
cmInformer = cache.NewSharedIndexInformer(cmListWatch, &v1.VirtualMachine{}, time.Second, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
Expand Down
26 changes: 20 additions & 6 deletions tests/vmlifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ var _ = Describe("Vmlifecycle", func() {
BeforeEach(func() {
allowEmuation := false
options := metav1.GetOptions{}
cfgMap, err := virtClient.CoreV1().ConfigMaps("kube-system").Get("virt-controller", options)
cfgMap, err := virtClient.CoreV1().ConfigMaps("kube-system").Get("kubevirt-config", options)
if err == nil {
val, ok := cfgMap.Data["debug.allowEmulation"]
allowEmuation = ok && (val == "true")
Expand All @@ -470,14 +470,17 @@ var _ = Describe("Vmlifecycle", func() {
listOptions := metav1.ListOptions{}
var pod k8sv1.Pod

Eventually(func() int {
Eventually(func() error {
podList, err := virtClient.CoreV1().Pods(tests.NamespaceTestDefault).List(listOptions)
Expect(err).ToNot(HaveOccurred())
if len(podList.Items) == 1 {
pod = podList.Items[0]
for _, item := range podList.Items {
if strings.HasPrefix(item.Name, vm.ObjectMeta.GenerateName) {
pod = item
return nil
}
}
return len(podList.Items)
}, 75, 0.5).Should(Equal(1))
return fmt.Errorf("Associated pod for VM '%s' not found", vm.Name)
}, 75, 0.5).Should(Succeed())

emulationFlagFound := false
computeContainerFound := false
Expand Down Expand Up @@ -509,6 +512,17 @@ var _ = Describe("Vmlifecycle", func() {
return len(podList.Items)
}, 75, 0.5).Should(Equal(1))

Eventually(func() error {
podList, err := virtClient.CoreV1().Pods(tests.NamespaceTestDefault).List(listOptions)
Expect(err).ToNot(HaveOccurred())
for _, item := range podList.Items {
if strings.HasPrefix(item.Name, vm.ObjectMeta.GenerateName) {
return nil
}
}
return fmt.Errorf("Associated pod for VM '%s' not found", vm.Name)
}, 75, 0.5).Should(Succeed())

getOptions := metav1.GetOptions{}
var newVm *v1.VirtualMachine

Expand Down

0 comments on commit ef9e3cb

Please sign in to comment.