14807: Escalate sigterm->sigkill->drain instance.
[arvados.git] / lib / dispatchcloud / driver.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package dispatchcloud
6
7 import (
8         "fmt"
9
10         "git.curoverse.com/arvados.git/lib/cloud"
11         "git.curoverse.com/arvados.git/lib/cloud/azure"
12         "git.curoverse.com/arvados.git/lib/cloud/ec2"
13         "git.curoverse.com/arvados.git/sdk/go/arvados"
14         "github.com/sirupsen/logrus"
15 )
16
17 var drivers = map[string]cloud.Driver{
18         "azure": azure.Driver,
19         "ec2":   ec2.Driver,
20 }
21
22 func newInstanceSet(cluster *arvados.Cluster, setID cloud.InstanceSetID, logger logrus.FieldLogger) (cloud.InstanceSet, error) {
23         driver, ok := drivers[cluster.CloudVMs.Driver]
24         if !ok {
25                 return nil, fmt.Errorf("unsupported cloud driver %q", cluster.CloudVMs.Driver)
26         }
27         return driver.InstanceSet(cluster.CloudVMs.DriverParameters, setID, logger)
28 }