aws

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2020 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasBugBrokenVPCCidrs added in v0.3.0

func HasBugBrokenVPCCidrs(meta MetadataClient) bool

HasBugBrokenVPCCidrs returns true if this instance has a known defective meta-data service which will not return secondary VPC CIDRs. As of January 2018, this covers c5 and m5 class hardware.

func Jitter added in v0.4.0

func Jitter(d time.Duration, pct float64) time.Duration

Jitter takes a duration and adjusts it forward by a up to `pct` percent uniformly.

Types

type AllocateClient added in v0.3.0

type AllocateClient interface {
	AllocateIPsOn(intf Interface, batchSize int64) ([]*AllocationResult, error)
	AllocateIPsFirstAvailableAtIndex(index int, batchSize int64) ([]*AllocationResult, error)
	AllocateIPsFirstAvailable(batchSize int64) ([]*AllocationResult, error)
	DeallocateIP(ipToRelease *net.IP) error
}

AllocateClient offers IP allocation on interfaces

type AllocationResult

type AllocationResult struct {
	*net.IP
	Interface Interface
}

AllocationResult contains a net.IP / Interface pair

func FindFreeIPsAtIndex added in v0.4.0

func FindFreeIPsAtIndex(index int, updateRegistry bool) ([]*AllocationResult, error)

FindFreeIPsAtIndex locates free IP addresses by comparing the assigned list from the EC2 metadata service and the currently used addresses within netlink. This is inherently somewhat racey - for example newly provisioned addresses may not show up immediately in metadata and are subject to a few seconds of delay.

type Bug added in v0.3.0

type Bug struct {
	Name   string
	HasBug func() bool
}

Bug defines a bug name and a function to check if the system is affected

func ListBugs added in v0.3.0

func ListBugs(meta MetadataClient) []Bug

ListBugs returns an enumerated set of all known bugs in AWS or instances that this instance is afflicted by

type Client added in v0.3.0

Client offers all of the supporting AWS services

var DefaultClient Client

DefaultClient that is setup with known defaults

type ENILimit

type ENILimit struct {
	Adapters int64
	IPv4     int64
	IPv6     int64
}

ENILimit contains limits for adapter count and addresses

type Interface

type Interface struct {
	ID     string
	Mac    string
	IfName string
	Number int
	IPv4s  []net.IP

	SubnetID   string
	SubnetCidr *net.IPNet

	VpcID            string
	VpcPrimaryCidr   *net.IPNet
	VpcCidrs         []*net.IPNet
	SecurityGroupIds []string
}

Interface describes an interface from the metadata service

func (Interface) LocalName

func (i Interface) LocalName() string

LocalName returns the instance name in string form

type InterfaceClient added in v0.3.0

type InterfaceClient interface {
	NewInterfaceOnSubnetAtIndex(index int, secGrps []string, subnet Subnet, ipBatchSize int64) (*Interface, error)
	NewInterface(secGrps []string, requiredTags map[string]string, ipBatchSize int64) (*Interface, error)
	RemoveInterface(interfaceIDs []string) error
}

InterfaceClient provides methods for allocating and deallocating interfaces

type Interfaces

type Interfaces []Interface

Interfaces contains a slice of Interface

func (Interfaces) Len

func (a Interfaces) Len() int

func (Interfaces) Less

func (a Interfaces) Less(i, j int) bool

func (Interfaces) Swap

func (a Interfaces) Swap(i, j int)

type LimitsClient added in v0.3.0

type LimitsClient interface {
	ENILimits() (*ENILimit, error)
}

LimitsClient provides methods for locating limits in AWS

type MetadataClient added in v0.3.0

type MetadataClient interface {
	Available() bool
	GetInterfaces() ([]Interface, error)
	InstanceType() string
}

MetadataClient provides methods to query the metadata service

type Registry added in v0.4.0

type Registry struct {
	// contains filtered or unexported fields
}

Registry defines a re-usable IP registry which tracks IPs that are free in the system and when they were last released back to the pool.

func (*Registry) Clear added in v0.4.0

func (r *Registry) Clear() error

Clear clears the registry unconditionally

func (*Registry) ForgetIP added in v0.4.0

func (r *Registry) ForgetIP(ip net.IP) error

ForgetIP removes an IP from the registry

func (*Registry) HasIP added in v0.4.0

func (r *Registry) HasIP(ip net.IP) (bool, error)

HasIP checks if an IP is in an registry

func (*Registry) List added in v0.4.0

func (r *Registry) List() (ret []net.IP, err error)

List returns a list of all tracked IPs

func (*Registry) TrackIP added in v0.4.0

func (r *Registry) TrackIP(ip net.IP) error

TrackIP records an IP in the free registry with the current system time as the current freed-time. If an IP is freed again, the time will be updated to the new current time.

func (*Registry) TrackIPAtEpoch added in v0.6.3

func (r *Registry) TrackIPAtEpoch(ip net.IP) error

TrackIPAtEpoch sets the IP recorded time as the epoch (0 time) so it appears as immediately free and avoids re-allocation

func (*Registry) TrackedBefore added in v0.4.0

func (r *Registry) TrackedBefore(t time.Time) ([]net.IP, error)

TrackedBefore returns a list of all IPs last recorded time _before_ the time passed to this function. You probably want to call this with time.Now().Add(-duration).

type Subnet

type Subnet struct {
	ID                    string
	Cidr                  string
	IsDefault             bool
	AvailableAddressCount int
	Name                  string
	Tags                  map[string]string
}

Subnet contains attributes of a subnet

type SubnetsByAvailableAddressCount

type SubnetsByAvailableAddressCount []Subnet

SubnetsByAvailableAddressCount contains a list of subnet

func (SubnetsByAvailableAddressCount) Len

func (SubnetsByAvailableAddressCount) Less

func (SubnetsByAvailableAddressCount) Swap

func (a SubnetsByAvailableAddressCount) Swap(i, j int)

type SubnetsClient added in v0.3.0

type SubnetsClient interface {
	GetSubnetsForInstance() ([]Subnet, error)
}

SubnetsClient provides information about VPC subnets

type VPCClient added in v0.3.0

type VPCClient interface {
	DescribeVPCCIDRs(vpcID string) ([]*net.IPNet, error)
	DescribeVPCPeerCIDRs(vpcID string) ([]*net.IPNet, error)
}

VPCClient provides a view into a VPC

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL