mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Add support for preemptible instances in node-e2e
Preemptible instances are cheaper, and the small chanse of a vm being killed doesn't matter when running during development. This is a tradeoff the user should be able to decide on. More info here: https://cloud.google.com/compute/docs/instances/preemptible The default setting is false, so unless setting PREEMPTIBLE_INSTANCES=true, everything will behave as before. Signed-off-by: Odin Ugedal <odin@ugedal.com>
This commit is contained in:
parent
4e7fd98763
commit
e20c2b1f32
@ -238,6 +238,8 @@ define TEST_E2E_NODE_HELP_INFO
|
|||||||
# run tests against. Defaults to "".
|
# run tests against. Defaults to "".
|
||||||
# DELETE_INSTANCES: For REMOTE=true only. Delete any instances created as
|
# DELETE_INSTANCES: For REMOTE=true only. Delete any instances created as
|
||||||
# part of this test run. Defaults to false.
|
# part of this test run. Defaults to false.
|
||||||
|
# PREEMPTIBLE_INSTANCES: For REMOTE=true only. Mark created gce instances
|
||||||
|
# as preemptible. Defaults to false.
|
||||||
# ARTIFACTS: For REMOTE=true only. Local directory to scp test artifacts into
|
# ARTIFACTS: For REMOTE=true only. Local directory to scp test artifacts into
|
||||||
# from the remote hosts. Defaults to "/tmp/_artifacts".
|
# from the remote hosts. Defaults to "/tmp/_artifacts".
|
||||||
# REPORT: For REMOTE=false only. Local directory to write juntil xml results
|
# REPORT: For REMOTE=false only. Local directory to write juntil xml results
|
||||||
|
@ -94,6 +94,7 @@ if [ "${remote}" = true ] ; then
|
|||||||
instance_prefix=${INSTANCE_PREFIX:-"test"}
|
instance_prefix=${INSTANCE_PREFIX:-"test"}
|
||||||
cleanup=${CLEANUP:-"true"}
|
cleanup=${CLEANUP:-"true"}
|
||||||
delete_instances=${DELETE_INSTANCES:-"false"}
|
delete_instances=${DELETE_INSTANCES:-"false"}
|
||||||
|
preemptible_instances=${PREEMPTIBLE_INSTANCES:-"false"}
|
||||||
test_suite=${TEST_SUITE:-"default"}
|
test_suite=${TEST_SUITE:-"default"}
|
||||||
|
|
||||||
# Get the compute zone
|
# Get the compute zone
|
||||||
@ -149,7 +150,7 @@ if [ "${remote}" = true ] ; then
|
|||||||
--image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
|
--image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
|
||||||
--delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
|
--delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
|
||||||
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
|
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
|
||||||
--extra-envs="${extra_envs}" --test-suite="${test_suite}" \
|
--preemptible-instances="${preemptible_instances}" --extra-envs="${extra_envs}" --test-suite="${test_suite}" \
|
||||||
2>&1 | tee -i "${artifacts}/build-log.txt"
|
2>&1 | tee -i "${artifacts}/build-log.txt"
|
||||||
exit $?
|
exit $?
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ var imageConfigFile = flag.String("image-config-file", "", "yaml file describing
|
|||||||
var imageConfigDir = flag.String("image-config-dir", "", "(optional)path to image config files")
|
var imageConfigDir = flag.String("image-config-dir", "", "(optional)path to image config files")
|
||||||
var imageProject = flag.String("image-project", "", "gce project the hosts live in")
|
var imageProject = flag.String("image-project", "", "gce project the hosts live in")
|
||||||
var images = flag.String("images", "", "images to test")
|
var images = flag.String("images", "", "images to test")
|
||||||
|
var preemptibleInstances = flag.Bool("preemptible-instances", false, "If true, gce instances will be configured to be preemptible")
|
||||||
var hosts = flag.String("hosts", "", "hosts to test")
|
var hosts = flag.String("hosts", "", "hosts to test")
|
||||||
var cleanup = flag.Bool("cleanup", true, "If true remove files from remote hosts and delete temporary instances")
|
var cleanup = flag.Bool("cleanup", true, "If true remove files from remote hosts and delete temporary instances")
|
||||||
var deleteInstances = flag.Bool("delete-instances", true, "If true, delete any instances created")
|
var deleteInstances = flag.Bool("delete-instances", true, "If true, delete any instances created")
|
||||||
@ -599,14 +600,15 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scheduling := compute.Scheduling{
|
||||||
|
Preemptible: *preemptibleInstances,
|
||||||
|
}
|
||||||
for _, accelerator := range imageConfig.resources.Accelerators {
|
for _, accelerator := range imageConfig.resources.Accelerators {
|
||||||
if i.GuestAccelerators == nil {
|
if i.GuestAccelerators == nil {
|
||||||
autoRestart := true
|
autoRestart := true
|
||||||
i.GuestAccelerators = []*compute.AcceleratorConfig{}
|
i.GuestAccelerators = []*compute.AcceleratorConfig{}
|
||||||
i.Scheduling = &compute.Scheduling{
|
scheduling.OnHostMaintenance = "TERMINATE"
|
||||||
OnHostMaintenance: "TERMINATE",
|
scheduling.AutomaticRestart = &autoRestart
|
||||||
AutomaticRestart: &autoRestart,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
aType := fmt.Sprintf(acceleratorTypeResourceFormat, *project, *zone, accelerator.Type)
|
aType := fmt.Sprintf(acceleratorTypeResourceFormat, *project, *zone, accelerator.Type)
|
||||||
ac := &compute.AcceleratorConfig{
|
ac := &compute.AcceleratorConfig{
|
||||||
@ -615,7 +617,7 @@ func createInstance(imageConfig *internalGCEImage) (string, error) {
|
|||||||
}
|
}
|
||||||
i.GuestAccelerators = append(i.GuestAccelerators, ac)
|
i.GuestAccelerators = append(i.GuestAccelerators, ac)
|
||||||
}
|
}
|
||||||
|
i.Scheduling = &scheduling
|
||||||
i.Metadata = imageConfig.metadata
|
i.Metadata = imageConfig.metadata
|
||||||
if _, err := computeService.Instances.Get(*project, *zone, i.Name).Do(); err != nil {
|
if _, err := computeService.Instances.Get(*project, *zone, i.Name).Do(); err != nil {
|
||||||
op, err := computeService.Instances.Insert(*project, *zone, i).Do()
|
op, err := computeService.Instances.Insert(*project, *zone, i).Do()
|
||||||
|
Loading…
Reference in New Issue
Block a user