Documentation ¶
Index ¶
- Constants
- func NewStreamManager(configurationManagerClient nspAPI.ConfigurationManagerClient, ...) *streamManager
- type Conduit
- func (c *Conduit) AddStream(ctx context.Context, strm *ambassadorAPI.Stream) error
- func (c *Conduit) Connect(ctx context.Context) error
- func (c *Conduit) Disconnect(ctx context.Context) error
- func (c *Conduit) Equals(conduit *ambassadorAPI.Conduit) bool
- func (c *Conduit) GetConduit() *ambassadorAPI.Conduit
- func (c *Conduit) GetIPs() []string
- func (c *Conduit) GetStreams() []*ambassadorAPI.Stream
- func (c *Conduit) RemoveStream(ctx context.Context, strm *ambassadorAPI.Stream) error
- func (c *Conduit) SetVIPs(ctx context.Context, vips []string) error
- type Configuration
- type StreamFactory
- type StreamManager
Constants ¶
const (
PendingTime = 15 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func NewStreamManager ¶
func NewStreamManager(configurationManagerClient nspAPI.ConfigurationManagerClient, targetRegistryClient nspAPI.TargetRegistryClient, streamRegistry types.Registry, streamFactory StreamFactory, timeout time.Duration, nspEntryTimeout time.Duration) *streamManager
Types ¶
type Conduit ¶
type Conduit struct { // Should be a unique name TargetName string // Namespace of the trench Namespace string Conduit *ambassadorAPI.Conduit // Node name the pod is running on NodeName string NetworkServiceClient networkservice.NetworkServiceClient MonitorConnectionClient networkservice.MonitorConnectionClient Configuration Configuration StreamManager StreamManager NetUtils networking.Utils StreamFactory StreamFactory // contains filtered or unexported fields }
Conduit implements types.Conduit (/pkg/ambassador/tap/types) Responsible for requesting/closing the NSM Connection to the conduit, managing the streams and configuring the VIPs.
func New ¶
func New(conduit *ambassadorAPI.Conduit, targetName string, namespace string, nodeName string, configurationManagerClient nspAPI.ConfigurationManagerClient, targetRegistryClient nspAPI.TargetRegistryClient, networkServiceClient networkservice.NetworkServiceClient, monitorConnectionClient networkservice.MonitorConnectionClient, streamRegistry types.Registry, netUtils networking.Utils, nspEntryTimeout time.Duration) (*Conduit, error)
New is the constructor of Conduit. The constructor will create a new stream factory and a VIP configuration watcher
func (*Conduit) AddStream ¶
AddStream creates a stream based on its factory and will open it (in another goroutine)
func (*Conduit) Connect ¶
Connect requests the connection to NSM and, if success, will open all streams added and watch the VIPs. Will also try to query NSM if a connection with the same ID already exists. If it does, try to re-use that connection to avoid interference (e.g., when old connection's token lifetime expires).
Rational behind using the same connection (segment) ID on the TAPA side: IPs assigned to the NSM connection might be restored even if the Proxy side segment ID changes (e.g., due to proxy kill, upgrade etc.). Thus, there might be no need to update localIPs, hence avoiding update of NSP and LBs about Target IP changes. It also avoids leaking the IPs of "old" TAPA->Proxy connections if the proxy POD has been replaced.
If connection was not re-used with the help of connectionMonitor: - Token expiration of "old" connection would lead to a heal event, which could trigger reconnect (depends on both datapath monitoring state and results). - Reconnect re-creates the NSM interfaces. Likely resulting in new MAC addresses causing traffic disturbances even if "old" localIPs were kept (mostly due to the neighbor cache in LB). - Tear down of old connection would make the IPAM release the IPs shared by two connection. (Released IPs could be re-acquired shortly in case of reconnect. But without reconnect IPs could get re-assigned more likely to some other connection.)
func (*Conduit) Disconnect ¶
Disconnect closes the connection from NSM, closes all streams and stop the VIP watcher
func (*Conduit) Equals ¶
func (c *Conduit) Equals(conduit *ambassadorAPI.Conduit) bool
Equals checks if the conduit is equal to the one in parameter
func (*Conduit) GetConduit ¶
func (c *Conduit) GetConduit() *ambassadorAPI.Conduit
func (*Conduit) GetStreams ¶
func (c *Conduit) GetStreams() []*ambassadorAPI.Stream
GetStreams returns all streams previously added to this conduit
func (*Conduit) RemoveStream ¶
RemoveStream closes and removes the stream (if existing), and removes it from the stream registry.
type Configuration ¶
type Configuration interface { Watch() Stop() }
type StreamFactory ¶
type StreamFactory interface {
New(*ambassadorAPI.Stream) (types.Stream, error)
}
The factory gathers common properties to simplify the instanciation of new streams. Mostly useful for the tests.
type StreamManager ¶
type StreamManager interface { // AddStream adds the stream to the stream manager, registers it to the // stream registry, creates a new stream based on StreamFactory, and open it, if // the stream manager is running and if the stream exists in the configuration. AddStream(strm *ambassadorAPI.Stream) error // RemoveStream removes the stream from the manager, removes it // from the stream registry and closes it. RemoveStream(context.Context, *ambassadorAPI.Stream) error // GetStreams returns the list of streams (opened or not). GetStreams() []*ambassadorAPI.Stream // Set all streams available in the conduit SetStreams([]*nspAPI.Stream) // Run open all streams registered and set their // status based on the ones available in the conduit. Run() // Stop closes all streams Stop(context.Context) error }
streamManager is responsible for: - opening/closing streams based of the streams available in the conduit. - Re-opening streams which have been closed by another resource (NSP failures...). - setting the status of the streams