File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/clusterfuzz/_internal/google_cloud_utils Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,16 @@ def _get_task_spec(batch_workload_spec):
144144 return task_spec
145145
146146
147+ def _set_preemptible (instance_policy ,
148+ batch_workload_spec : BatchWorkloadSpec ) -> None :
149+ if batch_workload_spec .preemptible :
150+ instance_policy .provisioning_model = (
151+ batch .AllocationPolicy .ProvisioningModel .PREEMPTIBLE )
152+ else :
153+ instance_policy .provisioning_model = (
154+ batch .AllocationPolicy .ProvisioningModel .STANDARD )
155+
156+
147157def _get_allocation_policy (spec ):
148158 """Returns the allocation policy for a BatchWorkloadSpec."""
149159 disk = batch .AllocationPolicy .Disk ()
@@ -153,6 +163,7 @@ def _get_allocation_policy(spec):
153163 instance_policy = batch .AllocationPolicy .InstancePolicy ()
154164 instance_policy .boot_disk = disk
155165 instance_policy .machine_type = spec .machine_type
166+ _set_preemptible (instance_policy , spec )
156167 instances = batch .AllocationPolicy .InstancePolicyOrTemplate ()
157168 instances .policy = instance_policy
158169
You can’t perform that action at this time.
0 commit comments