saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.17k stars 5.48k forks source link

gce: support preemptible instances #31606

Closed jparal closed 6 years ago

jparal commented 8 years ago

it seems that libcloud supports preemptible instances on GCE using ex_preemptible argument:

http://libcloud.readthedocs.org/en/latest/compute/drivers/gce.html

any plans on supporting this in salt-cloud? thx

jfindlay commented 8 years ago

@jparal, thanks for reporting. I think this is something that we can support.

cconrad commented 8 years ago

+1

rodoyle commented 7 years ago

+1

It appears that the kwargs dictionary in the gce client is simply not bringing in the 'ex_preemptible' setting. It could be as simple as extending this, though how to test it properly escapes me at the moment.

OrlandoArcapix commented 7 years ago

Just quickly patched this in to gce.py and tested working okay:

index 9a4f5e3..e7bfa10 100644
--- a/salt/cloud/clouds/gce.py
+++ b/salt/cloud/clouds/gce.py
@@ -2255,7 +2255,9 @@ def request_instance(vm_):
             'ex_service_accounts': config.get_cloud_config_value(
                 'ex_service_accounts', vm_, __opts__, default=None),
             'ex_can_ip_forward': config.get_cloud_config_value(
-                'ip_forwarding', vm_, __opts__, default=False
+                'ip_forwarding', vm_, __opts__, default=False),
+           'ex_preemptible': config.get_cloud_config_value(
+               'preemptible', vm_, __opts__, default=False
             )
         })
         if kwargs.get('ex_disk_type') not in ('pd-standard', 'pd-ssd'):

Together with the option in the cloud-profile

  preemptible: true

User test results after creating one with "preemptible: true" and one without preemptible set as an option:

$ gcloud compute instances list | egrep '(preempt|NAME)'
NAME                 ZONE            MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS
notpreempttest01     europe-west1-b  n1-standard-1               xx.xxx.x.x   xxx.xxx.xxx.xx  RUNNING
preempttest01        europe-west1-b  n1-standard-1  true         xx.xxx.x.x   xxx.xxx.xx.x    RUNNING

Looks like it will require libcloud > 0.20.0: https://libcloud.readthedocs.io/en/latest/changelog.html#id31

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.