Skip to content

Commit

Permalink
Stateless CNI changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
behzad-mir committed Nov 2, 2023
1 parent 98aa7ef commit 85b217a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cns/NetworkContainerContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
PathDebugRestData = "/debug/restdata"
NumberOfCPUCores = NumberOfCPUCoresPath
NMAgentSupportedAPIs = NmAgentSupportedApisPath
EndpointApi = EndpointPath
EndpointAPI = EndpointPath
)

// NetworkContainer Prefixes
Expand Down
6 changes: 3 additions & 3 deletions cns/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var clientPaths = []string{
cns.DeleteNetworkContainer,
cns.NetworkContainersURLPath,
cns.GetHomeAz,
cns.EndpointApi,
cns.EndpointAPI,
}

type do interface {
Expand Down Expand Up @@ -1026,7 +1026,7 @@ func (c *Client) GetHomeAz(ctx context.Context) (*cns.GetHomeAzResponse, error)
// GetEndpoint calls the EndpointHandlerAPI in CNS to retrieve the state of a given EndpointID
func (c *Client) GetEndpoint(ctx context.Context, endpointID string) (*restserver.GetEndpointResponse, error) {
// build the request
u := c.routes[cns.EndpointApi]
u := c.routes[cns.EndpointAPI]
uString := u.String() + endpointID
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uString, http.NoBody)
if err != nil {
Expand Down Expand Up @@ -1071,7 +1071,7 @@ func (c *Client) UpdateEndpoint(ctx context.Context, endpointID, hnsID, vethName
return nil, errors.Wrap(err, "failed to encode updateEndpoint")
}

u := c.routes[cns.EndpointApi]
u := c.routes[cns.EndpointAPI]
uString := u.String() + endpointID
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, uString, &body)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions network/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type EndpointInfo struct {
NATInfo []policy.NATInfo
NICType cns.NICType
SkipDefaultRoutes bool
HNSEndpointID string
}

// RouteInfo contains information about an IP route.
Expand Down
7 changes: 3 additions & 4 deletions network/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type NetworkManager interface {
FindNetworkIDFromNetNs(netNs string) (string, error)
GetNumEndpointsByContainerID(containerID string) int

CreateEndpoint(client apipaClient, networkID string, epInfo *EndpointInfo) error
CreateEndpoint(client apipaClient, networkID string, epInfo []*EndpointInfo) error
DeleteEndpoint(networkID string, endpointID string, epInfo *EndpointInfo) error
GetEndpointInfo(networkID string, endpointID string) (*EndpointInfo, error)
GetAllEndpoints(networkID string) (map[string]*EndpointInfo, error)
Expand Down Expand Up @@ -386,8 +386,7 @@ func (nm *networkManager) CreateEndpoint(cli apipaClient, networkID string, epIn
epInfo[0].Data[VlanIDKey] = nw.VlanId
}
}

_, err = nw.newEndpoint(cli, nm.netlink, nm.plClient, nm.netio, nm.nsClient, epInfo)
ep, err := nw.newEndpoint(cli, nm.netlink, nm.plClient, nm.netio, nm.nsClient, epInfo)
if err != nil {
return err
}
Expand Down Expand Up @@ -467,7 +466,7 @@ func (nm *networkManager) DeleteEndpointState(networkID string, epInfo *Endpoint
NetworkContainerID: epInfo.Id,
}
logger.Info("Deleting endpoint with", zap.String("Endpoint Info: ", epInfo.PrettyString()), zap.String("HNISID : ", ep.HnsId))
return nw.deleteEndpointImpl(netlink.NewNetlink(), platform.NewExecClient(logger), nil, ep)
return nw.deleteEndpointImpl(netlink.NewNetlink(), platform.NewExecClient(logger), nil, nil, ep)
}

// GetEndpointInfo returns information about the given endpoint.
Expand Down
2 changes: 1 addition & 1 deletion network/manager_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (nm *MockNetworkManager) CreateEndpoint(_ apipaClient, _ string, epInfos []
}

// DeleteEndpoint mock
func (nm *MockNetworkManager) DeleteEndpoint(networkID string, endpointID string, ep *EndpointInfo) error {
func (nm *MockNetworkManager) DeleteEndpoint(_, endpointID string, _ *EndpointInfo) error {
delete(nm.TestEndpointInfoMap, endpointID)
return nil
}
Expand Down

0 comments on commit 85b217a

Please sign in to comment.