restserver

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MIT Imports: 42 Imported by: 2

Documentation

Index

Constants

View Source
const (
	GetHomeAzAPIName = "GetHomeAz"
	ContextTimeOut   = 2 * time.Second
)
View Source
const (
	EndpointStoreKey = "Endpoints"
)
View Source
const SWIFT = "SWIFT-POSTROUTING"

Variables

View Source
var (
	ErrStoreEmpty       = errors.New("empty endpoint state store")
	ErrParsePodIPFailed = errors.New("failed to parse pod's ip")
)
View Source
var (
	ErrInvalidNcURLFormat = errors.New("Invalid network container url format")
)

Functions

func ResponseCodeToError

func ResponseCodeToError(responseCode types.ResponseCode) error

ResponseCodeToError converts a cns response code to error type. If the response code is OK, then return value is nil

Types

type CNIConflistGenerator

type CNIConflistGenerator interface {
	Generate() error
	Close() error
}

type CNSRESTError

type CNSRESTError struct {
	ResponseCode types.ResponseCode
}

CNSRESTError represents a CNS error

func (*CNSRESTError) Error

func (c *CNSRESTError) Error() string

type EndpointInfo

type EndpointInfo struct {
	PodName       string
	PodNamespace  string
	IfnameToIPMap map[string]*IPInfo // key : interface name, value : IPInfo
}

type GetHTTPServiceDataResponse

type GetHTTPServiceDataResponse struct {
	HTTPRestServiceData HTTPRestServiceData
	Response            Response
}

type HTTPRestService

type HTTPRestService struct {
	*cns.Service

	PodIPIDByPodInterfaceKey map[string][]string                  // PodInterfaceId is key and value is slice of Pod IP (SecondaryIP) uuids.
	PodIPConfigState         map[string]cns.IPConfigurationStatus // Secondary IP ID(uuid) is key
	IPAMPoolMonitor          cns.IPAMPoolMonitor

	sync.RWMutex

	EndpointState      map[string]*EndpointInfo // key : container id
	EndpointStateStore store.KeyValueStore
	// contains filtered or unexported fields
}

HTTPRestService represents http listener for CNS - Container Networking Service.

func NewHTTPRestService

func NewHTTPRestService(config *common.ServiceConfig, wscli interfaceGetter, wsproxy wireserverProxy, nmagentClient nmagentClient,
	endpointStateStore store.KeyValueStore, gen CNIConflistGenerator, homeAzMonitor *HomeAzMonitor,
) (*HTTPRestService, error)

NewHTTPRestService creates a new HTTP Service object.

func (*HTTPRestService) AssignAvailableIPConfigs

func (service *HTTPRestService) AssignAvailableIPConfigs(podInfo cns.PodInfo) ([]cns.PodIpInfo, error)

Assigns an available IP from each NC on the NNC. If there is one NC then we expect to only have one IP return In the case of dualstack we would expect to have one IPv6 from one NC and one IPv4 from a second NC

func (*HTTPRestService) AssignDesiredIPConfigs

func (service *HTTPRestService) AssignDesiredIPConfigs(podInfo cns.PodInfo, desiredIPAddresses []string) ([]cns.PodIpInfo, error)

Assigns a pod with all IPs desired

func (*HTTPRestService) CreateOrUpdateNetworkContainerInternal

func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.CreateNetworkContainerRequest) types.ResponseCode

This API will be called by CNS RequestController on CRD update.

func (*HTTPRestService) DeleteNetworkContainerInternal

func (service *HTTPRestService) DeleteNetworkContainerInternal(
	req cns.DeleteNetworkContainerRequest,
) types.ResponseCode

DeleteNetworkContainerInternal deletes a network container.

func (*HTTPRestService) GetAssignedIPConfigs

func (service *HTTPRestService) GetAssignedIPConfigs() []cns.IPConfigurationStatus

GetAssignedIPConfigs returns a filtered list of IPs which are in Assigned State.

func (*HTTPRestService) GetAvailableIPConfigs

func (service *HTTPRestService) GetAvailableIPConfigs() []cns.IPConfigurationStatus

GetAvailableIPConfigs returns a filtered list of IPs which are in Available State.

func (*HTTPRestService) GetExistingIPConfig

func (service *HTTPRestService) GetExistingIPConfig(podInfo cns.PodInfo) ([]cns.PodIpInfo, bool, error)

Returns the current IP configs for a pod if they exist

func (*HTTPRestService) GetNetworkContainerInternal

func (service *HTTPRestService) GetNetworkContainerInternal(
	req cns.GetNetworkContainerRequest,
) (cns.GetNetworkContainerResponse, types.ResponseCode)

GetNetworkContainerInternal gets network container details.

func (*HTTPRestService) GetPartitionKey

func (service *HTTPRestService) GetPartitionKey() (dncPartitionKey string)

GetPartitionKey - Get dnc/service partition key

func (*HTTPRestService) GetPendingProgramIPConfigs

func (service *HTTPRestService) GetPendingProgramIPConfigs() []cns.IPConfigurationStatus

GetPendingProgramIPConfigs returns a filtered list of IPs which are in PendingProgramming State.

func (*HTTPRestService) GetPendingReleaseIPConfigs

func (service *HTTPRestService) GetPendingReleaseIPConfigs() []cns.IPConfigurationStatus

GetPendingReleaseIPConfigs returns a filtered list of IPs which are in PendingRelease State.

func (*HTTPRestService) GetPodIPConfigState

func (service *HTTPRestService) GetPodIPConfigState() map[string]cns.IPConfigurationStatus

func (*HTTPRestService) Init

func (service *HTTPRestService) Init(config *common.ServiceConfig) error

Init starts the CNS listener.

func (*HTTPRestService) MarkExistingIPsAsPendingRelease

func (service *HTTPRestService) MarkExistingIPsAsPendingRelease(pendingIPIDs []string) error

MarkExistingIPsAsPendingRelease is called when CNS is starting up and there are existing ipconfigs in the CRD that are marked as pending.

func (*HTTPRestService) MarkIPAsPendingRelease

func (service *HTTPRestService) MarkIPAsPendingRelease(totalIpsToRelease int) (map[string]cns.IPConfigurationStatus, error)

MarkIPAsPendingRelease will set the IPs which are in PendingProgramming or Available to PendingRelease state It will try to update [totalIpsToRelease] number of ips.

func (*HTTPRestService) MarkIpsAsAvailableUntransacted

func (service *HTTPRestService) MarkIpsAsAvailableUntransacted(ncID string, newHostNCVersion int)

MarkIpsAsAvailableUntransacted will update pending programming IPs to available if NMAgent side's programmed nc version keep up with nc version. Note: this func is an untransacted API as the caller will take a Service lock

func (*HTTPRestService) MustGenerateCNIConflistOnce

func (service *HTTPRestService) MustGenerateCNIConflistOnce()

MustGenerateCNIConflistOnce will generate the CNI conflist once if the service was initialized with a conflist generator. If not, this is a no-op.

func (*HTTPRestService) ReconcileNCState added in v1.1.7

func (service *HTTPRestService) ReconcileNCState(ncRequest *cns.CreateNetworkContainerRequest, podInfoByIP map[string]cns.PodInfo, nnc *v1alpha.NodeNetworkConfig) types.ResponseCode

This API will be called by CNS RequestController on CRD update.

func (*HTTPRestService) RegisterPProfEndpoints

func (service *HTTPRestService) RegisterPProfEndpoints()

func (*HTTPRestService) SendNCSnapShotPeriodically

func (service *HTTPRestService) SendNCSnapShotPeriodically(ctx context.Context, ncSnapshotIntervalInMinutes int)

Sets up periodic timer for sending network container snapshots

func (*HTTPRestService) SetNodeOrchestrator

func (service *HTTPRestService) SetNodeOrchestrator(r *cns.SetOrchestratorTypeRequest)

SetNodeOrchestrator :- Set node orchestrator after registering with mDNC

func (*HTTPRestService) Start

func (service *HTTPRestService) Start(config *common.ServiceConfig) error

Start starts the CNS listener.

func (*HTTPRestService) Stop

func (service *HTTPRestService) Stop()

Stop stops the CNS.

func (*HTTPRestService) SyncHostNCVersion

func (service *HTTPRestService) SyncHostNCVersion(ctx context.Context, channelMode string)

SyncHostNCVersion will check NC version from NMAgent and save it as host NC version in container status. If NMAgent NC version got updated, CNS will refresh the pending programming IP status.

func (*HTTPRestService) SyncNodeStatus

func (service *HTTPRestService) SyncNodeStatus(dncEP, infraVnet, nodeID string, contextFromCNI json.RawMessage) (returnCode types.ResponseCode, errStr string)

type HTTPRestServiceData

type HTTPRestServiceData struct {
	PodIPIDByPodInterfaceKey map[string][]string                  // PodInterfaceId is key and value is slice of Pod IP uuids.
	PodIPConfigState         map[string]cns.IPConfigurationStatus // secondaryipid(uuid) is key
	IPAMPoolMonitor          cns.IpamPoolMonitorStateSnapshot
}

HTTPRestServiceData represents in-memory CNS data in the debug API paths.

type HomeAzMonitor

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

func NewHomeAzMonitor

func NewHomeAzMonitor(client nmagentClient, cacheRefreshIntervalSecs time.Duration) *HomeAzMonitor

NewHomeAzMonitor creates a new HomeAzMonitor object

func (*HomeAzMonitor) GetHomeAz

GetHomeAz returns home az cache value directly

func (*HomeAzMonitor) Populate

func (h *HomeAzMonitor) Populate(ctx context.Context)

Populate makes call to nmagent to retrieve home az if getHomeAz api is supported by nmagent

func (*HomeAzMonitor) Start

func (h *HomeAzMonitor) Start()

Start starts a new thread to refresh home az cache

func (*HomeAzMonitor) Stop

func (h *HomeAzMonitor) Stop()

Stop ends the refresh thread

type IPInfo

type IPInfo struct {
	IPv4 []net.IPNet
	IPv6 []net.IPNet
}

type NoOpConflistGenerator

type NoOpConflistGenerator struct{}

func (*NoOpConflistGenerator) Close

func (*NoOpConflistGenerator) Close() error

func (*NoOpConflistGenerator) Generate

func (*NoOpConflistGenerator) Generate() error

type Response

type Response struct {
	ReturnCode types.ResponseCode
	Message    string
}

Jump to

Keyboard shortcuts

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