restserver

package
v1.4.18 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 38 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidNcURLFormat = errors.New("Invalid network container url format")
)

Functions

func NewHTTPRestService

func NewHTTPRestService(config *common.ServiceConfig, wscli interfaceGetter, nmagentClient nmagentClient) (cns.HTTPService, error)

NewHTTPRestService creates a new HTTP Service object.

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 CNSRESTError

type CNSRESTError struct {
	ResponseCode types.ResponseCode
}

CNSRESTError represents a CNS error

func (*CNSRESTError) Error

func (c *CNSRESTError) Error() string

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 Pod IP (SecondaryIP) uuid.
	PodIPConfigState         map[string]cns.IPConfigurationStatus // Secondary IP ID(uuid) is key
	IPAMPoolMonitor          cns.IPAMPoolMonitor

	sync.RWMutex
	// contains filtered or unexported fields
}

HTTPRestService represents http listener for CNS - Container Networking Service.

func (*HTTPRestService) AssignAnyAvailableIPConfig added in v1.4.17

func (service *HTTPRestService) AssignAnyAvailableIPConfig(podInfo cns.PodInfo) (cns.PodIpInfo, error)

func (*HTTPRestService) AssignDesiredIPConfig added in v1.4.17

func (service *HTTPRestService) AssignDesiredIPConfig(podInfo cns.PodInfo, desiredIPAddress string) (cns.PodIpInfo, error)

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)

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) MarkExistingIPsAsPending added in v1.1.8

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

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) 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) 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)

SyncNodeStatus :- Retrieve the latest node state from DNC & returns the first occurence of returnCode and error with respect to contextFromCNI

type HTTPRestServiceData

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

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

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