Skip to content

Conversation

@saiyan86
Copy link
Contributor

@saiyan86 saiyan86 commented Dec 25, 2017

What this PR does / why we need it:

  1. Enable outboundNAT for Windows containers.
  2. Handle consecutive ADD calls for the same container.
  3. Handle attach endpoint for workload containers.

Which issue this PR fixes

Related issue: [https://github.com/kubernetes/kubernetes/issues/57253](url)

log.Printf("[net] Created endpoint %+v.", ep)

return ep, nil

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if netNsPath != "" {
splits := strings.Split(netNsPath, ":")
if len(splits) == 2 {
epName = splits[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment here..briefly explaining two cases if and else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

epName = containerID
}
if len(epName) > 8 {
epName = epName[:8] + "-" + ifName
Copy link
Member

@tamilmani1989 tamilmani1989 Dec 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we choosing first 8 characters of ContainerID? Will the first 8 characters will be unique for all containers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We construct endpoint ID using first 8 characters of containerID and interface name. Please check plugin.go line 162-168.

// newEndpointImpl creates a new endpoint in the network.
func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) {
// Ignore consecutive ADD calls for the same container.
if nw.Endpoints[epInfo.Id] != nil {
Copy link
Member

@tamilmani1989 tamilmani1989 Dec 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one you are using as a key in Endpoints map - epName or epinfo.Id ? In line 54, you are using epName as key for same map. Are both same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epinfo.Id is generated from containerID of ADD call. If the ADD call is for infrastructure container, then epName == epinfo.id. Basic, when I use epName as a key for nw.Endpoints, I am handling the ADD call for workload container. I want to return the endpoint for infrastructure container, since these two containers belong to the same pod. Reference: https://kubernetes.io/docs/concepts/cluster-administration/networking/#kubernetes-model

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you got it. Checking GetHNSEndpointByName not nil solves object already exists issue. Can you please add some details in function description?

}

//enable outbound NAT
var enableOutBoundNat = json.RawMessage(`{"Type": "OutBoundNAT"}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have unit test for testing this function? If its there, can we add one to test this property is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write unit test for this. We can discuss this.

nw.Endpoints[epInfo.Id] = ep

log.Printf("[net] Created endpoint %+v.", ep)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this empty line also. not needed

Copy link
Member

@tamilmani1989 tamilmani1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@sharmasushant sharmasushant merged commit 4bc51cc into Azure:master Dec 28, 2017
@saiyan86 saiyan86 deleted the outboundNAT branch December 28, 2017 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants