18992: Fix broken-node-hook global flag.
[arvados.git] / lib / dispatchcloud / driver.go
index f2a6c9263027dc2d765fc79720ec8bfeae2606e6..5fcc0903f5d1b43d3b58e83d8e6721832985c4ed 100644 (file)
@@ -17,7 +17,7 @@ import (
        "golang.org/x/crypto/ssh"
 )
 
-// Map of available cloud drivers.
+// Drivers is a map of available cloud drivers.
 // Clusters.*.Containers.CloudVMs.Driver configuration values
 // correspond to keys in this map.
 var Drivers = map[string]cloud.Driver{
@@ -55,6 +55,15 @@ type rateLimitedInstanceSet struct {
        ticker *time.Ticker
 }
 
+func (is rateLimitedInstanceSet) Instances(tags cloud.InstanceTags) ([]cloud.Instance, error) {
+       <-is.ticker.C
+       insts, err := is.InstanceSet.Instances(tags)
+       for i, inst := range insts {
+               insts[i] = &rateLimitedInstance{inst, is.ticker}
+       }
+       return insts, err
+}
+
 func (is rateLimitedInstanceSet) Create(it arvados.InstanceType, image cloud.ImageID, tags cloud.InstanceTags, init cloud.InitCommand, pk ssh.PublicKey) (cloud.Instance, error) {
        <-is.ticker.C
        inst, err := is.InstanceSet.Create(it, image, tags, init, pk)
@@ -71,6 +80,11 @@ func (inst *rateLimitedInstance) Destroy() error {
        return inst.Instance.Destroy()
 }
 
+func (inst *rateLimitedInstance) SetTags(tags cloud.InstanceTags) error {
+       <-inst.ticker.C
+       return inst.Instance.SetTags(tags)
+}
+
 // Adds the specified defaultTags to every Create() call.
 type defaultTaggingInstanceSet struct {
        cloud.InstanceSet
@@ -180,7 +194,6 @@ func (inst instrumentedInstance) SetTags(tags cloud.InstanceTags) error {
 func boolLabelValue(v bool) string {
        if v {
                return "1"
-       } else {
-               return "0"
        }
+       return "0"
 }