restserver

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Success                                = 0
	UnsupportedNetworkType                 = 1
	InvalidParameter                       = 2
	UnsupportedEnvironment                 = 3
	UnreachableHost                        = 4
	ReservationNotFound                    = 5
	MalformedSubnet                        = 8
	UnreachableDockerDaemon                = 9
	UnspecifiedNetworkName                 = 10
	NotFound                               = 14
	AddressUnavailable                     = 15
	NetworkContainerNotSpecified           = 16
	CallToHostFailed                       = 17
	UnknownContainerID                     = 18
	UnsupportedOrchestratorType            = 19
	DockerContainerNotSpecified            = 20
	UnsupportedVerb                        = 21
	UnsupportedNetworkContainerType        = 22
	InvalidRequest                         = 23
	NetworkJoinFailed                      = 24
	NetworkContainerPublishFailed          = 25
	NetworkContainerUnpublishFailed        = 26
	InvalidPrimaryIPConfig                 = 27
	PrimaryCANotSame                       = 28
	InconsistentIPConfigState              = 29
	InvalidSecondaryIPConfig               = 30
	NetworkContainerVfpProgramPending      = 31
	FailedToAllocateIpConfig               = 32
	EmptyOrchestratorContext               = 33
	UnsupportedOrchestratorContext         = 34
	NetworkContainerVfpProgramComplete     = 35
	NetworkContainerVfpProgramCheckSkipped = 36
	NmAgentSupportedApisError              = 37
	UnsupportedNCVersion                   = 38
	UnexpectedError                        = 99
)

Container Network Service remote API Contract.

Variables

This section is empty.

Functions

func NewHTTPRestService

func NewHTTPRestService(config *common.ServiceConfig, imdsClientInterface imdsclient.ImdsClientInterface, nmagentClient nmagentclient.NMAgentClientInterface) (cns.HTTPService, error)

NewHTTPRestService creates a new HTTP Service object.

func ReturnCodeToString added in v1.0.16

func ReturnCodeToString(returnCode int) (s string)

ReturnCodeToString - Converts an error code to appropriate string.

Types

type GetHTTPServiceDataResponse

type GetHTTPServiceDataResponse struct {
	HttpRestServiceData HttpRestServiceData
	Response            Response
}

type HTTPRestService

type HTTPRestService struct {
	*cns.Service

	PodIPIDByOrchestratorContext map[string]string                    // OrchestratorContext is key and value is Pod IP uuid.
	PodIPConfigState             map[string]cns.IPConfigurationStatus // seondaryipid(uuid) is key
	IPAMPoolMonitor              cns.IPAMPoolMonitor

	sync.RWMutex
	// contains filtered or unexported fields
}

HTTPRestService represents http listener for CNS - Container Networking Service.

func (*HTTPRestService) AllocateAnyAvailableIPConfig added in v1.1.5

func (service *HTTPRestService) AllocateAnyAvailableIPConfig(podInfo cns.KubernetesPodInfo, orchestratorContext json.RawMessage) (cns.PodIpInfo, error)

func (*HTTPRestService) AllocateDesiredIPConfig added in v1.1.5

func (service *HTTPRestService) AllocateDesiredIPConfig(podInfo cns.KubernetesPodInfo, desiredIPAddress string, orchestratorContext json.RawMessage) (cns.PodIpInfo, error)

func (*HTTPRestService) CreateOrUpdateNetworkContainerInternal

func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req cns.CreateNetworkContainerRequest) int

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

func (*HTTPRestService) DeleteNetworkContainerInternal

func (service *HTTPRestService) DeleteNetworkContainerInternal(req cns.DeleteNetworkContainerRequest) int

DeleteNetworkContainerInternal deletes a network container.

func (*HTTPRestService) GetAllocatedIPConfigs added in v1.1.6

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

func (*HTTPRestService) GetAvailableIPConfigs

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

func (*HTTPRestService) GetExistingIPConfig

func (service *HTTPRestService) GetExistingIPConfig(podInfo cns.KubernetesPodInfo) (cns.PodIpInfo, bool, error)

func (*HTTPRestService) GetHTTPRestDataHandler added in v1.2.9

func (service *HTTPRestService) GetHTTPRestDataHandler(w http.ResponseWriter, r *http.Request)

func (*HTTPRestService) GetHTTPStruct added in v1.2.9

func (service *HTTPRestService) GetHTTPStruct() HttpRestServiceData

func (*HTTPRestService) GetNetworkContainerInternal

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

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 list of IPs which are in pending program status

func (*HTTPRestService) GetPendingReleaseIPConfigs

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

func (*HTTPRestService) GetPodIPConfigState

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

func (*HTTPRestService) GetPodIPIDByOrchestratorContext added in v1.2.9

func (service *HTTPRestService) GetPodIPIDByOrchestratorContext() map[string]string

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.KubernetesPodInfo, scalar nnc.Scaler, spec nnc.NodeNetworkConfigSpec) int

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

func (*HTTPRestService) SendNCSnapShotPeriodically

func (service *HTTPRestService) SendNCSnapShotPeriodically(ncSnapshotIntervalInMinutes int, stopSnapshot chan bool)

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, syncHostNCTimeoutMilliSec time.Duration)

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 int, errStr string)

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

func (*HTTPRestService) UpdateIPAMPoolMonitorInternal added in v1.4.1

func (service *HTTPRestService) UpdateIPAMPoolMonitorInternal(scalar nnc.Scaler, spec nnc.NodeNetworkConfigSpec) int

type HttpRestServiceData added in v1.2.9

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

struct to return in-memory httprest data in debug api

type Response

type Response struct {
	ReturnCode int
	Message    string
}

Jump to

Keyboard shortcuts

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