Skip to content
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

Merged
merged 6 commits into from
Feb 3, 2021

Conversation

ruicao93
Copy link
Contributor

@ruicao93 ruicao93 commented Jan 25, 2021

  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 missing OVS port.

Fixes: #1679

Signed-off-by: Rui Cao rcao@vmware.com

@ruicao93 ruicao93 changed the title [Windows] ContainerD support [WIP][Windows] ContainerD support Jan 25, 2021
@codecov-io
Copy link

codecov-io commented Jan 25, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@d5634b5). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1781   +/-   ##
=======================================
  Coverage        ?   42.79%           
=======================================
  Files           ?      109           
  Lines           ?    13605           
  Branches        ?        0           
=======================================
  Hits            ?     5822           
  Misses          ?     7296           
  Partials        ?      487           
Flag Coverage Δ
unit-tests 42.79% <0.00%> (?)

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>
@ruicao93
Copy link
Contributor Author

/test-all

@ruicao93
Copy link
Contributor Author

/test-conformance

@antoninbas
Copy link
Contributor

antoninbas commented Jan 25, 2021

@ruicao93 could you link it to the appropriate issue ? #1679 I believe

Base automatically changed from master to main January 26, 2021 00:00
@ruicao93 ruicao93 changed the title [WIP][Windows] ContainerD support [Windows] ContainerD support Jan 26, 2021
@ruicao93
Copy link
Contributor Author

@ruicao93 could you link it to the appropriate issue ? #1679 I believe

Thanks Antonin. Add the issue link.

pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
Signed-off-by: Rui Cao <rcao@vmware.com>
@ruicao93
Copy link
Contributor Author

/test-all

Signed-off-by: Rui Cao <rcao@vmware.com>
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
go.sum Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
// 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.
Copy link
Contributor

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?

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 save a dummyMAC to avoid printing error in parseConfig(). The parseConfig fuinction will print error if MAC address not exists.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@antoninbas antoninbas left a 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

pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/server_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/interface_configuration_windows.go Outdated Show resolved Hide resolved
Comment on lines 292 to +293
} else {
if err := hcsshim.HotAttachEndpoint(containerID, ep.Id); err != nil {
if isInfraContainer(sandbox) || hcsshim.ErrComputeSystemDoesNotExist != err {
if hcnEp == nil {
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
pkg/agent/cniserver/pod_configuration_windows.go Outdated Show resolved Hide resolved
Signed-off-by: Rui Cao <rcao@vmware.com>
@ruicao93
Copy link
Contributor Author

ruicao93 commented Feb 1, 2021

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?

@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>
@ruicao93
Copy link
Contributor Author

ruicao93 commented Feb 2, 2021

/test-all

Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

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

LGTM.

@ruicao93 ruicao93 merged commit 1a53d76 into antrea-io:main Feb 3, 2021
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.

Windows Containerd Support short-term proposal
5 participants