Skip to content

Commit

Permalink
remove cni changes
Browse files Browse the repository at this point in the history
  • Loading branch information
behzad-mir committed Jan 19, 2024
1 parent aa0c7d5 commit f98b5b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ACN_VERSION ?= $(shell git describe --exclude "azure-ipam*" --exclude "dropgz
AZURE_IPAM_VERSION ?= $(notdir $(shell git describe --match "azure-ipam*" --tags --always))
CNI_VERSION ?= $(ACN_VERSION)
CNI_DROPGZ_VERSION ?= $(notdir $(shell git describe --match "dropgz*" --tags --always))
CNS_VERSION ?= $(ACN_VERSION)-k
CNS_VERSION ?= $(ACN_VERSION)-m
NPM_VERSION ?= $(ACN_VERSION)
ZAPAI_VERSION ?= $(notdir $(shell git describe --match "zapai*" --tags --always))

Expand Down
6 changes: 3 additions & 3 deletions cni/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type PodNetworkInterfaceInfo struct {
PodEndpointId string
ContainerID string
IPAddresses []net.IPNet
HostIfName string
HNSEndpointID string
IfName string
//HostIfName string
//HNSEndpointID string
//IfName string
}

type AzureCNIState struct {
Expand Down
4 changes: 3 additions & 1 deletion cni/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (c *client) GetEndpointState() (*api.AzureCNIState, error) {
if err := json.Unmarshal(output, state); err != nil {
return nil, fmt.Errorf("failed to decode response from Azure CNI when retrieving state: [%w], response from CNI: [%s]", err, string(output))
}

for containerID, endpointInfo := range state.ContainerInterfaces {
logger.Info("writing endpoint state from stateful CNI ", zap.String("podname:", containerID), zap.String("podname:", endpointInfo.PodName), zap.Any("endpoint:", endpointInfo))
}
return state, nil
}

Expand Down
6 changes: 3 additions & 3 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func (plugin *NetPlugin) GetAllEndpointState(networkid string) (*api.AzureCNISta
PodEndpointId: ep.Id,
ContainerID: ep.ContainerID,
IPAddresses: ep.IPAddresses,
HostIfName: ep.HostIfName,
HNSEndpointID: ep.HNSEndpointID,
IfName: ep.IfName,
//HostIfName: ep.HostIfName,
//HNSEndpointID: ep.HNSEndpointID,
//IfName: ep.IfName,
}

st.ContainerInterfaces[id] = info
Expand Down
7 changes: 4 additions & 3 deletions cns/cnireconciler/podinfoprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func cniStateToPodInfoByIP(state *api.AzureCNIState) (map[string]cns.PodInfo, er
for _, endpoint := range state.ContainerInterfaces {
for _, epIP := range endpoint.IPAddresses {
podInfo := cns.NewPodInfo(endpoint.ContainerID, endpoint.PodEndpointId, endpoint.PodName, endpoint.PodNamespace)

logger.Printf("podInfoByIp [%+v]", podInfoByIP)
ipKey := epIP.IP.String()
if prevPodInfo, ok := podInfoByIP[ipKey]; ok {
return nil, errors.Wrapf(cns.ErrDuplicateIP, "duplicate ip %s found for different pods: pod: %+v, pod: %+v", ipKey, podInfo, prevPodInfo)
Expand All @@ -71,6 +71,7 @@ func cniStateToPodInfoByIP(state *api.AzureCNIState) (map[string]cns.PodInfo, er
podInfoByIP[ipKey] = podInfo
}
}
logger.Printf("podInfoByIP [%+v]", podInfoByIP)
return podInfoByIP, nil
}

Expand Down Expand Up @@ -112,7 +113,7 @@ func cniStateToCnsEndpointState(state *api.AzureCNIState) (map[string]*restserve
logger.Printf("Generating CNS ENdpoint State")
endpointState := map[string]*restserver.EndpointInfo{}
for _, endpoint := range state.ContainerInterfaces {
endpointInfo := &restserver.EndpointInfo{PodName: endpoint.PodName, PodNamespace: endpoint.PodNamespace, HnsEndpointID: endpoint.HNSEndpointID, HostVethName: endpoint.HostIfName, IfnameToIPMap: make(map[string]*restserver.IPInfo)}
endpointInfo := &restserver.EndpointInfo{PodName: endpoint.PodName, PodNamespace: endpoint.PodNamespace, IfnameToIPMap: make(map[string]*restserver.IPInfo)}
ipInfo := &restserver.IPInfo{}
for _, epIP := range endpoint.IPAddresses {
if epIP.IP.To4() == nil { // is an ipv6 address
Expand All @@ -136,7 +137,7 @@ func cniStateToCnsEndpointState(state *api.AzureCNIState) (map[string]*restserve
ipInfo.IPv4 = append(ipInfo.IPv4, ipconfig)
}
}
endpointInfo.IfnameToIPMap[endpoint.IfName] = ipInfo
endpointInfo.IfnameToIPMap["eth0"] = ipInfo
logger.Printf("writing endpoint podName from stateful CNI %v", endpoint.PodName)
logger.Printf("writing endpoint info from stateful CNI [%+v]", *endpointInfo)
endpointState[endpoint.ContainerID] = endpointInfo
Expand Down

0 comments on commit f98b5b1

Please sign in to comment.