cockroach: Index | Files | Directories

package vm

import ""


Package Files



var (
    ErrBadNetwork   = errors.New("could not determine network information")
    ErrInvalidName  = errors.New("invalid VM name")
    ErrNoExpiration = errors.New("could not determine expiration")

Error values for VM.Error

var Providers = map[string]Provider{}

Providers contains all known Provider instances. This is initialized by subpackage init() functions.

func AllProviderNames Uses

func AllProviderNames() []string

AllProviderNames returns the names of all known vm Providers. This is useful with the ProvidersSequential or ProvidersParallel methods.

func ExpandZonesFlag Uses

func ExpandZonesFlag(zoneFlag []string) (zones []string, err error)

ExpandZonesFlag takes a slice of strings which may be of the format zone:N which implies that a given zone should be repeated N times and expands it. For example ["us-west1-b:2", "us-east1-a:2"] will expand to ["us-west1-b", "us-west1-b", "us-east1-a", "us-east1-a"].

func FanOut Uses

func FanOut(list List, action func(Provider, List) error) error

FanOut collates a collection of VMs by their provider and invoke the callbacks in parallel.

func FindActiveAccounts Uses

func FindActiveAccounts() (map[string]string, error)

FindActiveAccounts queries the active providers for the name of the user account.

func ForProvider Uses

func ForProvider(named string, action func(Provider) error) error

ForProvider resolves the Provider with the given name and executes the action.

func Name Uses

func Name(cluster string, idx int) string

Name generates the name for the i'th node in a cluster.

func ProvidersParallel Uses

func ProvidersParallel(named []string, action func(Provider) error) error

ProvidersParallel concurrently executes actions for each named Provider.

func ProvidersSequential Uses

func ProvidersSequential(named []string, action func(Provider) error) error

ProvidersSequential sequentially executes actions for each named Provider.

func ZonePlacement Uses

func ZonePlacement(numZones, numNodes int) (nodeZones []int)

ZonePlacement allocates zones to numNodes in an equally sized groups in the same order as zones. If numNodes is not divisible by len(zones) the remainder is allocated in a round-robin fashion and placed at the end of the returned slice. The returned slice has a length of numNodes where each value is in [0, numZones).

For example:

ZonePlacement(3, 8) = []int{0, 0, 1, 1, 2, 2, 0, 1}

type CreateOpts Uses

type CreateOpts struct {
    ClusterName    string
    Lifetime       time.Duration
    GeoDistributed bool
    VMProviders    []string
    SSDOpts        struct {
        UseLocalSSD bool
        // NoExt4Barrier, if set, makes the "-o nobarrier" flag be used when
        // mounting the SSD. Ignored if UseLocalSSD is not set.
        NoExt4Barrier bool

CreateOpts is the set of options when creating VMs.

type DeleteCluster Uses

type DeleteCluster interface {
    DeleteCluster(name string) error

DeleteCluster is an optional capability for a Provider which can destroy an entire cluster in a single operation.

type List Uses

type List []VM

List represents a list of VMs.

func (List) Len Uses

func (vl List) Len() int

func (List) Less Uses

func (vl List) Less(i, j int) bool

func (List) Names Uses

func (vl List) Names() []string

Names sxtracts all VM.Name entries from the List

func (List) ProviderIDs Uses

func (vl List) ProviderIDs() []string

ProviderIDs extracts all ProviderID values from the List.

func (List) Swap Uses

func (vl List) Swap(i, j int)

type MultipleProjectsOption Uses

type MultipleProjectsOption bool

MultipleProjectsOption is used to specify whether a command accepts multiple values for the --gce-project flag.

const (
    // SingleProject means that a single project is accepted.
    SingleProject MultipleProjectsOption = false
    // AcceptMultipleProjects means that multiple projects are supported.
    AcceptMultipleProjects = true

type Provider Uses

type Provider interface {
    CleanSSH() error
    ConfigSSH() error
    Create(names []string, opts CreateOpts) error
    Delete(vms List) error
    Extend(vms List, lifetime time.Duration) error
    // Return the account name associated with the provider
    FindActiveAccount() (string, error)
    // Returns a hook point for extending top-level roachprod tooling flags
    Flags() ProviderFlags
    List() (List, error)
    // The name of the Provider, which will also surface in the top-level Providers map.
    Name() string

    // Active returns true if the provider is properly installed and capable of
    // operating, false if it's just a stub. This allows one to test whether a
    // particular provider is functioning properly by doin, for example,
    // Providers[gce.ProviderName].Active. Note that just looking at
    // Providers[gce.ProviderName] != nil doesn't work because
    // Providers[gce.ProviderName] can be a stub.
    Active() bool

A Provider is a source of virtual machines running on some hosting platform.

type ProviderFlags Uses

type ProviderFlags interface {
    // Configures a FlagSet with any options relevant to the `create` command.
    // Configures a FlagSet with any options relevant to cluster manipulation
    // commands (`create`, `destroy`, `list`, `sync` and `gc`).
    ConfigureClusterFlags(*pflag.FlagSet, MultipleProjectsOption)

ProviderFlags is a hook point for Providers to supply additional, provider-specific flags to various roachprod commands. In general, the flags should be prefixed with the provider's name to prevent collision between similar options.

If a new command is added (perhaps `roachprod enlarge`) that needs additional provider- specific flags, add a similarly-named method `ConfigureEnlargeFlags` to mix in the additional flags.

type VM Uses

type VM struct {
    Name      string    `json:"name"`
    CreatedAt time.Time `json:"created_at"`
    // If non-empty, indicates that some or all of the data in the VM instance
    // is not present or otherwise invalid.
    Errors   []error       `json:"errors"`
    Lifetime time.Duration `json:"lifetime"`
    // The provider-internal DNS name for the VM instance
    DNS string `json:"dns"`
    // The name of the cloud provider that hosts the VM instance
    Provider string `json:"provider"`
    // The provider-specific id for the instance.  This may or may not be the same as Name, depending
    // on whether or not the cloud provider automatically assigns VM identifiers.
    ProviderID string `json:"provider_id"`
    PrivateIP  string `json:"private_ip"`
    PublicIP   string `json:"public_ip"`
    // The username that should be used to connect to the VM.
    RemoteUser string `json:"remote_user"`
    // The VPC value defines an equivalency set for VMs that can route
    // to one another via private IP addresses.  We use this later on
    // when determining whether or not cluster member should advertise
    // their public or private IP.
    VPC         string `json:"vpc"`
    MachineType string `json:"machine_type"`
    Zone        string `json:"zone"`
    // Project represents the project to which this vm belongs, if the VM is in a
    // cloud that supports project (i.e. GCE). Empty otherwise.
    Project string `json:"project"`

A VM is an abstract representation of a specific machine instance. This type is used across the various cloud providers supported by roachprod.

func (*VM) IsLocal Uses

func (vm *VM) IsLocal() bool

IsLocal returns true if the VM represents the local host.

func (*VM) Locality Uses

func (vm *VM) Locality() string

Locality returns the cloud, region, and zone for the VM. We want to include the cloud, since GCE and AWS use similarly-named regions (e.g. us-east-1)


aws/terraformgenCommand terraformgen generate the terraform file used to configure AWS for multiregion support.
azurePackage azure allows roachprod to create instances within the Microsoft Azure cloud.

Package vm imports 10 packages (graph) and is imported by 7 packages. Updated 2020-07-10. Refresh now. Tools for package owners.