-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] ContainerD support #1781
Conversation
080a7f4
to
02ff879
Compare
Codecov Report
@@ Coverage Diff @@
## main #1781 +/- ##
=======================================
Coverage ? 42.79%
=======================================
Files ? 109
Lines ? 13605
Branches ? 0
=======================================
Hits ? 5822
Misses ? 7296
Partials ? 487
Flags with carried forward coverage won't be shown. Click here to find out more. |
1. Use HCS API for container network configuration. 2. Create OVS port asynchronously. When using ContainerD as runtime, network interface is created after sandbox container creation complete. So Antrea needs to wait for network interface realized before creating OVS port. 3. Use HNSEndpoint to cache params which are used to create OVS port. During boot stage, antrea-agent could leverage the cached params to create missed OVS port. Signed-off-by: Rui Cao <rcao@vmware.com>
02ff879
to
f8074f7
Compare
/test-all |
/test-conformance |
Signed-off-by: Rui Cao <rcao@vmware.com>
07db605
to
c3cf0d2
Compare
/test-all |
Signed-off-by: Rui Cao <rcao@vmware.com>
Signed-off-by: Rui Cao <rcao@vmware.com>
if _, err := net.InterfaceByName(ifaceName); err == nil { | ||
return true | ||
} | ||
cmd := fmt.Sprintf(`Get-NetAdapter -InterfaceAlias "%s"`, ifaceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some comments to explain why need to run the PS command to check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Add comments:
// Some kinds of interface cannot be retrieved by "net.InterfaceByName" such as
// container vnic.
// So if a interface cannot be found by above function, use powershell command
// "Get-NetAdapter" to check if it exists.
// The name is same as the OVS port name and HNSEndpoint name. | ||
// - containerID: Used as key for goroutine lock to avoid concurrency issue. | ||
// - podName and PodNamespace: Used to identify the owner of the HNSEndpoint. | ||
// - dummyMac: the MAC address of the HNSEndpoint is unknown before we create it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, then why we need to save dummyMAC? To indicate the real MAC is not known?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We save a dummyMAC to avoid printing error in parseConfig(). The parseConfig fuinction will print error if MAC address not exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change ParseOVSPortInterfaceConfig() in this case, like a flag to indicate whether MAC should be present, or change to let its callers check whether MAC is present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I add a checkMac
param to ParseOVSPortInterfaceConfig()
to determine if print error msg after parse MAC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple more minor comments, otherwise LGTM
} else { | ||
if err := hcsshim.HotAttachEndpoint(containerID, ep.Id); err != nil { | ||
if isInfraContainer(sandbox) || hcsshim.ErrComputeSystemDoesNotExist != err { | ||
if hcnEp == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use an else if
"statement" to avoid one level of indentation
btw the hcnEp == nil
case means that the container runtime is docker correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, hcnEp == nil
means the runtime is Docker.
I want to keep them in same level.
if hcnEp == nil {
// docker ops
} else {
// containerd ops
}
if hcnEndpoint != nil && hcnEndpoint.HostComputeNamespace != "" { | ||
err := hcn.RemoveNamespaceEndpoint(hcnEndpoint.HostComputeNamespace, hcnEndpoint.Id) | ||
if err != nil { | ||
klog.Errorf("Failed to remove HostComputeEndpoint %s from HostComputeNameSpace %s: %v", hcnEndpoint.Name, hcnEndpoint.HostComputeNamespace, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for pointing it out.
Then maybe let's always log the error in the goroutine (also for the call to endpoint.Delete
below), assuming it is an actual error (and not "not found").
Then, also assuming it is an actual error, we can write it to the deleteCh
channel. To avoid double logging, we can
change the select case for deleteCh
to:
case err := <-deleteCh:
if err != nil {
return err
}
What do you think?
Signed-off-by: Rui Cao <rcao@vmware.com>
@antoninbas , sounds great. I move the error check and logging in gorutine, and only return result here. |
Signed-off-by: Rui Cao <rcao@vmware.com>
adf8769
to
df3c8bf
Compare
/test-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
network interface is created after sandbox container creation
complete. So Antrea needs to wait for network interface realized
before creating OVS port.
During boot stage, antrea-agent could leverage the cached params
to create missing OVS port.
Fixes: #1679
Signed-off-by: Rui Cao rcao@vmware.com