14930: Adds --trash-at & --trash-after arguments to arv-put (WIP)
[arvados.git] / lib / dispatchcloud / worker / pool.go
index 81a658535ea593a7a0a0c2d9231fd66f3055bdbd..014ab93bfe9c7289bcd99286379a3a26bbc38b18 100644 (file)
@@ -691,6 +691,18 @@ func (wp *Pool) Instances() []InstanceView {
        return r
 }
 
+// KillInstance destroys a cloud VM instance. It returns an error if
+// the given instance does not exist.
+func (wp *Pool) KillInstance(id cloud.InstanceID, reason string) error {
+       wkr, ok := wp.workers[id]
+       if !ok {
+               return errors.New("instance not found")
+       }
+       wkr.logger.WithField("Reason", reason).Info("shutting down")
+       wkr.shutdown()
+       return nil
+}
+
 func (wp *Pool) setup() {
        wp.creating = map[string]createCall{}
        wp.exited = map[string]time.Time{}