aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/instance
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-03-28 13:20:58 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-03-28 13:22:37 +0100
commit742f448304a916ae83bcdadf7e3be76c5464b37b (patch)
tree7f6e741df6470ae90f8d04c55a0e4e9afe6eb814 /pkg/instance
parentf94f56fe6b1c892eb8cddc28e24e0290c68de003 (diff)
vm/gce: allow non-preemptible VMs
We are seeing some flakes during bisection and image testing. Hard to tell what's the root cause because they are episodic. But using non-preemptible VMs for bisection and image testing looks good on all fronts. Update #501
Diffstat (limited to 'pkg/instance')
-rw-r--r--pkg/instance/instance.go44
1 files changed, 19 insertions, 25 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go
index 7df34d191..d92c25cfa 100644
--- a/pkg/instance/instance.go
+++ b/pkg/instance/instance.go
@@ -90,42 +90,36 @@ func (env *Env) BuildKernel(compilerBin, userspaceDir, cmdlineFile, sysctlFile s
cmdlineFile, sysctlFile, kernelConfig); err != nil {
return err
}
- return SetConfigImage(cfg, imageDir)
+ return SetConfigImage(cfg, imageDir, true)
}
-func SetConfigImage(cfg *mgrconfig.Config, imageDir string) error {
+func SetConfigImage(cfg *mgrconfig.Config, imageDir string, reliable bool) error {
cfg.KernelObj = filepath.Join(imageDir, "obj")
cfg.Image = filepath.Join(imageDir, "image")
if keyFile := filepath.Join(imageDir, "key"); osutil.IsExist(keyFile) {
cfg.SSHKey = keyFile
}
+ vmConfig := make(map[string]interface{})
+ if err := json.Unmarshal(cfg.VM, &vmConfig); err != nil {
+ return fmt.Errorf("failed to parse VM config: %v", err)
+ }
if cfg.Type == "qemu" || cfg.Type == "vmm" {
- kernel := filepath.Join(imageDir, "kernel")
- if !osutil.IsExist(kernel) {
- kernel = ""
+ if kernel := filepath.Join(imageDir, "kernel"); osutil.IsExist(kernel) {
+ vmConfig["kernel"] = kernel
}
- initrd := filepath.Join(imageDir, "initrd")
- if !osutil.IsExist(initrd) {
- initrd = ""
- }
- if kernel != "" || initrd != "" {
- vmConfig := make(map[string]interface{})
- if err := json.Unmarshal(cfg.VM, &vmConfig); err != nil {
- return fmt.Errorf("failed to parse VM config: %v", err)
- }
- if kernel != "" {
- vmConfig["kernel"] = kernel
- }
- if initrd != "" {
- vmConfig["initrd"] = initrd
- }
- vmCfg, err := json.Marshal(vmConfig)
- if err != nil {
- return fmt.Errorf("failed to serialize VM config: %v", err)
- }
- cfg.VM = vmCfg
+ if initrd := filepath.Join(imageDir, "initrd"); osutil.IsExist(initrd) {
+ vmConfig["initrd"] = initrd
}
}
+ if cfg.Type == "gce" {
+ // Don't use preemptible VMs for image testing, patch testing and bisection.
+ vmConfig["preemptible"] = !reliable
+ }
+ vmCfg, err := json.Marshal(vmConfig)
+ if err != nil {
+ return fmt.Errorf("failed to serialize VM config: %v", err)
+ }
+ cfg.VM = vmCfg
return nil
}