Documentation ¶
Index ¶
- Constants
- func GetInterfaceName(acsENI *ecsacs.ElasticNetworkInterface) string
- func IsUnableToFindENIError(err error) bool
- func NetNSName(taskID, eniName string) string
- func NewUnableToFindENIError(macAddress, associationProtocol string) error
- func ValidateENI(acsENI *ecsacs.ElasticNetworkInterface) error
- type DNSMapping
- type ENIAttachment
- func (eni *ENIAttachment) GetAttachmentARN() string
- func (eni *ENIAttachment) GetAttachmentStatus() attachment.AttachmentStatus
- func (eni *ENIAttachment) GetAttachmentType() string
- func (eni *ENIAttachment) HasExpired() bool
- func (eni *ENIAttachment) Initialize(timeoutFunc func()) error
- func (eni *ENIAttachment) IsSent() bool
- func (eni *ENIAttachment) SetAttachedStatus()
- func (eni *ENIAttachment) SetSentStatus()
- func (eni *ENIAttachment) ShouldAttach() bool
- func (eni *ENIAttachment) ShouldNotify() bool
- func (eni *ENIAttachment) StartTimer(timeoutFunc func()) error
- func (eni *ENIAttachment) StopAckTimer()
- func (eni *ENIAttachment) String() string
- type IPV4Address
- type IPV6Address
- type InterfaceVlanProperties
- type NetworkInterface
- func (ni *NetworkInterface) GetHostname() string
- func (ni *NetworkInterface) GetIPAddressesWithPrefixLength() []string
- func (ni *NetworkInterface) GetIPV4Addresses() []string
- func (ni *NetworkInterface) GetIPV6Addresses() []string
- func (ni *NetworkInterface) GetIPv4SubnetCIDRBlock() string
- func (ni *NetworkInterface) GetIPv4SubnetPrefixLength() string
- func (ni *NetworkInterface) GetIPv6SubnetCIDRBlock() string
- func (ni *NetworkInterface) GetLinkName() string
- func (ni *NetworkInterface) GetPrimaryIPv4Address() string
- func (ni *NetworkInterface) GetPrimaryIPv4AddressWithPrefixLength() string
- func (ni *NetworkInterface) GetSubnetGatewayIPv4Address() string
- func (ni *NetworkInterface) IsPrimary() bool
- func (ni *NetworkInterface) IsStandardENI() bool
- func (ni *NetworkInterface) ShouldGenerateNetworkConfigFiles() bool
- func (ni *NetworkInterface) String() string
- type TunnelProperties
- type UnableToFindENIError
- type VETHProperties
Constants ¶
const ( // ENIAttachmentTypeTaskENI represents the type of a task level eni ENIAttachmentTypeTaskENI = "task-eni" // ENIAttachmentTypeInstanceENI represents the type of an instance level eni ENIAttachmentTypeInstanceENI = "instance-eni" )
const ( // DefaultInterfaceAssociationProtocol represents the standard NetworkInterface type. DefaultInterfaceAssociationProtocol = "default" // VLANInterfaceAssociationProtocol represents the NetworkInterface with trunking enabled. VLANInterfaceAssociationProtocol = "vlan" // IPv6SubnetPrefixLength is the IPv6 global unicast address prefix length, consisting of // global routing prefix and subnet ID lengths as specified in IPv6 addressing architecture // (RFC 4291 section 2.5.4) and IPv6 Global Unicast Address Format (RFC 3587). // The ACS NetworkInterface payload structure does not contain an IPv6 subnet prefix length because "/64" is // the only allowed length per RFCs above, and the only one that VPC supports. IPv6SubnetPrefixLength = "64" // TapDeviceNamePrefix holds the name prefix for interfaces attached to a MicroVM. // In a multi NetworkInterface task, there will be multiple tap ENIs attached to it. // They follow a naming pattern 'eth<eni index>'. TapDeviceNamePrefix = "eth" // DefaultTapDeviceName is the name of the tap device created by CNI plugin // which connects the MicroVM with the branch NetworkInterface. DefaultTapDeviceName = TapDeviceNamePrefix + "0" // VETHInterfaceAssociationProtocol is the interface association protocol for veth interfaces. VETHInterfaceAssociationProtocol = "veth" // V2NInterfaceAssociationProtocol is the interface association protocol for V2N tunnel interfaces. V2NInterfaceAssociationProtocol = "tunnel" // GeneveInterfaceNamePattern holds pattern of GENEVE interface name: // 'gnv<v2nVNI><destination port>'. // We have both the VNI and destination port in the name because that is the only // guaranteed combination that can make the name of the interface unique. // It is important that the name is unique for all GENEVE interfaces because // the interface is always first created in the default network namespace // before moving it to a custom namespace. GeneveInterfaceNamePattern = "gnv%s%d" // DefaultGeneveInterfaceIPAddress is the IP address that will be assigned to the // GENEVE interface created for the V2N NetworkInterface. These IP addresses are chosen because // they come under the ECS reserved link-local IP range. By having the subnet mask as /31, // it means there are only 2 available IPs in this chosen subnet - 169.254.175.252 and // 169.254.175.253. We set 169.254.175.252 as the geneve interface IP and set // 169.254.175.253 as the default default gateway in the routing rules. // We also assign a place holder MAC address for the gateway in the ARP table. This // configuration ensures all traffic generated in the V2N NetworkInterface's netns will pass through // the GENEVE interface. DefaultGeneveInterfaceIPAddress = "169.254.175.252" DefaultGeneveInterfaceGateway = "169.254.175.253/31" )
Variables ¶
This section is empty.
Functions ¶
func GetInterfaceName ¶
func GetInterfaceName(acsENI *ecsacs.ElasticNetworkInterface) string
GetInterfaceName creates the NetworkInterface name from the NetworkInterface mac address in case it is empty in the ACS payload.
func IsUnableToFindENIError ¶
IsUnableToFindENIError returns true if the error type is of type `UnableToFindENIError`.
func NetNSName ¶
NetNSName returns the netns name that the specified network interface will be attached to in a desired task.
func NewUnableToFindENIError ¶
NewUnableToFindENIError creates a new UnableToFindENIError object.
func ValidateENI ¶
func ValidateENI(acsENI *ecsacs.ElasticNetworkInterface) error
ValidateENI validates the NetworkInterface information sent from ACS.
Types ¶
type DNSMapping ¶
DNSMapping holds additional pre-defined DNS entries for containers. These additional entries will be written into /etc/hosts file eventually.
type ENIAttachment ¶
type ENIAttachment struct { attachment.AttachmentInfo // AttachmentType is the type of the eni attachment, can either be "task-eni" or "instance-eni" AttachmentType string `json:"attachmentType"` // MACAddress is the mac address of eni MACAddress string `json:"macAddress"` // contains filtered or unexported fields }
ENIAttachment contains the information of the eni attachment
func (*ENIAttachment) GetAttachmentARN ¶
func (eni *ENIAttachment) GetAttachmentARN() string
func (*ENIAttachment) GetAttachmentStatus ¶
func (eni *ENIAttachment) GetAttachmentStatus() attachment.AttachmentStatus
func (*ENIAttachment) GetAttachmentType ¶
func (eni *ENIAttachment) GetAttachmentType() string
func (*ENIAttachment) HasExpired ¶
func (eni *ENIAttachment) HasExpired() bool
HasExpired returns true if the ENI attachment object has exceeded the threshold for notifying the backend of the attachment
func (*ENIAttachment) Initialize ¶
func (eni *ENIAttachment) Initialize(timeoutFunc func()) error
Initialize initializes the fields that can't be populated from loading state file. Notably, this initializes the ack timer so that if we times out waiting for the eni to be attached, the attachment can be removed from state.
func (*ENIAttachment) IsSent ¶
func (eni *ENIAttachment) IsSent() bool
IsSent checks if the eni attached status has been sent
func (*ENIAttachment) SetAttachedStatus ¶
func (eni *ENIAttachment) SetAttachedStatus()
SetAttachedStatus marks the eni status as attached
func (*ENIAttachment) SetSentStatus ¶
func (eni *ENIAttachment) SetSentStatus()
SetSentStatus marks the eni attached status has been sent
func (*ENIAttachment) ShouldAttach ¶
func (eni *ENIAttachment) ShouldAttach() bool
func (*ENIAttachment) ShouldNotify ¶
func (eni *ENIAttachment) ShouldNotify() bool
should notify when attached, and not sent/not expired
func (*ENIAttachment) StartTimer ¶
func (eni *ENIAttachment) StartTimer(timeoutFunc func()) error
StartTimer starts the ack timer to record the expiration of ENI attachment
func (*ENIAttachment) StopAckTimer ¶
func (eni *ENIAttachment) StopAckTimer()
StopAckTimer stops the ack timer set on the ENI attachment
func (*ENIAttachment) String ¶
func (eni *ENIAttachment) String() string
String returns a string representation of the ENI Attachment
type IPV4Address ¶
type IPV4Address struct { // Primary indicates whether the ip address is primary Primary bool // Address is the ipv4 address associated with eni Address string }
IPV4Address is the ipv4 information of the eni
type IPV6Address ¶
type IPV6Address struct { // Address is the ipv6 address associated with eni Address string }
IPV6Address is the ipv6 information of the eni
type InterfaceVlanProperties ¶
InterfaceVlanProperties contains information for an interface that is supposed to be used as a VLAN device
type NetworkInterface ¶
type NetworkInterface struct { // ID is the id of eni ID string `json:"ec2Id"` // LinkName is the name of the NetworkInterface on the instance. // Currently, this field is being used only for Windows and is used during task networking setup. LinkName string // MacAddress is the mac address of the eni MacAddress string // IPV4Addresses is the ipv4 address associated with the eni IPV4Addresses []*IPV4Address // IPV6Addresses is the ipv6 address associated with the eni IPV6Addresses []*IPV6Address // SubnetGatewayIPV4Address is the IPv4 address of the subnet gateway of the NetworkInterface SubnetGatewayIPV4Address string `json:",omitempty"` // DomainNameServers specifies the nameserver IP addresses for the eni DomainNameServers []string `json:",omitempty"` // DomainNameSearchList specifies the search list for the domain // name lookup, for the eni DomainNameSearchList []string `json:",omitempty"` // PrivateDNSName is the dns name assigned by the vpc to this eni PrivateDNSName string `json:",omitempty"` // InterfaceAssociationProtocol is the type of NetworkInterface, valid value: "default", "vlan" InterfaceAssociationProtocol string `json:",omitempty"` Index int64 `json:"Index"` UserID uint32 `json:"UserID"` Name string `json:"Name"` DeviceName string `json:"DeviceName"` KnownStatus status.NetworkStatus `json:"KnownStatus"` DesiredStatus status.NetworkStatus `json:"DesiredStatus"` // GuestNetNSName represents the interface's network namespace inside a guest OS if applicable. // A sample use case is while running tasks inside Firecracker microVMs. GuestNetNSName string `json:"GuestNetNSName,omitempty"` // InterfaceVlanProperties contains information for an interface // that is supposed to be used as a VLAN device InterfaceVlanProperties *InterfaceVlanProperties `json:",omitempty"` // TunnelProperties contains information for tunnel interface TunnelProperties *TunnelProperties `json:",omitempty"` // VETHProperties contains information for a virtual ethernet interface VETHProperties *VETHProperties `json:",omitempty"` // Certain tasks such as service connect tasks may require additional // domain name to IP address mapping defined in their /etc/hosts files. // DNSMappingList will contain this for each NetworkInterface since /etc/hosts file // is created per NetworkInterface. DNSMappingList []DNSMapping // Default denotes whether the interface is responsible // for handling default route within the netns it resides in. Default bool // contains filtered or unexported fields }
NetworkInterface contains information of the network interface
func InterfaceFromACS ¶
func InterfaceFromACS(acsENI *ecsacs.ElasticNetworkInterface) (*NetworkInterface, error)
InterfaceFromACS validates the given ACS NetworkInterface information and creates an NetworkInterface object from it.
func New ¶
func New( acsENI *ecsacs.ElasticNetworkInterface, guestNetNSName string, ifaceList []*ecsacs.ElasticNetworkInterface, macToName map[string]string, ) (*NetworkInterface, error)
New creates a new NetworkInterface model.
func (*NetworkInterface) GetHostname ¶
func (ni *NetworkInterface) GetHostname() string
GetHostname returns the hostname assigned to the NetworkInterface
func (*NetworkInterface) GetIPAddressesWithPrefixLength ¶
func (ni *NetworkInterface) GetIPAddressesWithPrefixLength() []string
GetIPAddressesWithPrefixLength returns the list of all IP addresses assigned to the NetworkInterface with their subnet prefix length.
func (*NetworkInterface) GetIPV4Addresses ¶
func (ni *NetworkInterface) GetIPV4Addresses() []string
GetIPV4Addresses returns the list of IPv4 addresses assigned to the NetworkInterface.
func (*NetworkInterface) GetIPV6Addresses ¶
func (ni *NetworkInterface) GetIPV6Addresses() []string
GetIPV6Addresses returns the list of IPv6 addresses assigned to the NetworkInterface.
func (*NetworkInterface) GetIPv4SubnetCIDRBlock ¶
func (ni *NetworkInterface) GetIPv4SubnetCIDRBlock() string
GetIPv4SubnetCIDRBlock returns the IPv4 CIDR block, if any, of the NetworkInterface's subnet.
func (*NetworkInterface) GetIPv4SubnetPrefixLength ¶
func (ni *NetworkInterface) GetIPv4SubnetPrefixLength() string
GetIPv4SubnetPrefixLength returns the IPv4 prefix length of the NetworkInterface's subnet.
func (*NetworkInterface) GetIPv6SubnetCIDRBlock ¶
func (ni *NetworkInterface) GetIPv6SubnetCIDRBlock() string
GetIPv6SubnetCIDRBlock returns the IPv6 CIDR block, if any, of the NetworkInterface's subnet.
func (*NetworkInterface) GetLinkName ¶
func (ni *NetworkInterface) GetLinkName() string
GetLinkName returns the name of the NetworkInterface on the instance.
func (*NetworkInterface) GetPrimaryIPv4Address ¶
func (ni *NetworkInterface) GetPrimaryIPv4Address() string
GetPrimaryIPv4Address returns the primary IPv4 address assigned to the NetworkInterface.
func (*NetworkInterface) GetPrimaryIPv4AddressWithPrefixLength ¶
func (ni *NetworkInterface) GetPrimaryIPv4AddressWithPrefixLength() string
GetPrimaryIPv4AddressWithPrefixLength returns the primary IPv4 address assigned to the NetworkInterface with its subnet prefix length.
func (*NetworkInterface) GetSubnetGatewayIPv4Address ¶
func (ni *NetworkInterface) GetSubnetGatewayIPv4Address() string
GetSubnetGatewayIPv4Address returns the subnet gateway IPv4 address for the NetworkInterface.
func (*NetworkInterface) IsPrimary ¶
func (ni *NetworkInterface) IsPrimary() bool
IsPrimary returns whether the NetworkInterface is the primary NetworkInterface of the task.
func (*NetworkInterface) IsStandardENI ¶
func (ni *NetworkInterface) IsStandardENI() bool
IsStandardENI returns true if the NetworkInterface is a standard/regular NetworkInterface. That is, if it has its association protocol as standard. To be backwards compatible, if the association protocol is not set for an NetworkInterface, it's considered a standard NetworkInterface as well.
func (*NetworkInterface) ShouldGenerateNetworkConfigFiles ¶
func (ni *NetworkInterface) ShouldGenerateNetworkConfigFiles() bool
ShouldGenerateNetworkConfigFiles can be used to check if network configuration files (hosts, hostname and resolv.conf) need to be generated using this eni's information. In case of warmpool, network config files should only be generated for primary ENIs. But as part of multi-NetworkInterface implementation it was decided that for firecracker platform the files had to be generated for secondary ENIs as well. Hence the NetworkInterface IsPrimary check was moved from here to warmpool specific APIs.
func (*NetworkInterface) String ¶
func (ni *NetworkInterface) String() string
String returns a human-readable version of the NetworkInterface object
type TunnelProperties ¶
type TunnelProperties struct { ID string `json:"ID"` DestinationIPAddress string `json:"DestinationIPAddress"` DestinationPort uint16 `json:"DestinationPort"` }
TunnelProperties holds ID (e.g. VNI), destination IP address and port for tunnel interfaces.
type UnableToFindENIError ¶
type UnableToFindENIError struct {
// contains filtered or unexported fields
}
UnableToFindENIError is an error type that is used to handle cases where the ENI device cannot be found, even after it has been acknowledged as "attached" by the agent. It lets us special case this error in dispatcher and task director workflows.
func (*UnableToFindENIError) Error ¶
func (e *UnableToFindENIError) Error() string
type VETHProperties ¶
type VETHProperties struct {
PeerInterfaceName string `json:"PeerInterfaceName"`
}
VETHProperties holds the properties for virtual ethernet interfaces.