1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
11 "git.curoverse.com/arvados.git/sdk/go/arvados"
12 "golang.org/x/crypto/ssh"
15 // A RateLimitError should be returned by a Provider when the cloud
16 // service indicates it is rejecting all API calls for some time
18 type RateLimitError interface {
19 // Time before which the caller should expect requests to
21 EarliestRetry() time.Time
25 // A QuotaError should be returned by a Provider when the cloud
26 // service indicates the account cannot create more VMs than already
28 type QuotaError interface {
29 // If true, don't create more instances until some existing
30 // instances are destroyed. If false, don't handle the error
36 type InstanceTags map[string]string
37 type InstanceID string
40 // instance is implemented by the provider-specific instance types.
41 type Instance interface {
42 // ID returns the provider's instance ID. It must be stable
43 // for the life of the instance.
46 // String typically returns the cloud-provided instance ID.
50 Tags(context.Context) (InstanceTags, error)
52 // Replace tags with the given tags
53 SetTags(context.Context, InstanceTags) error
56 Destroy(context.Context) error
58 // SSH server hostname or IP address, or empty string if unknown pending creation.
62 type InstanceProvider interface {
63 // Create a new instance. If supported by the driver, add the
64 // provided public key to /root/.ssh/authorized_keys.
66 // The returned error should implement RateLimitError and
67 // QuotaError where applicable.
68 Create(context.Context, arvados.InstanceType, ImageID, InstanceTags, ssh.PublicKey) (Instance, error)
70 // Return all instances, including ones that are booting or
73 // An instance returned by successive calls to Instances() may
74 // -- but does not need to -- be represented by the same
75 // Instance object each time. Thus, the caller is responsible
76 // for de-duplicating the returned instances by comparing the
77 // InstanceIDs returned by the instances' ID() methods.
78 Instances(context.Context) ([]Instance, error)
80 // Stop any background tasks and release other resources.