Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Build CRI Plugin on Windows and Add Presubmit #1258

Merged
merged 3 commits into from Sep 3, 2019

Conversation

Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented Sep 2, 2019

For #1257.

This PR moves linux specific logic into _unix.go files, and make this buildable on windows.

This PR also adds appveyor presubmit test. We don't use travis windows support because travis only supports windows 1803 (https://docs.travis-ci.com/user/reference/windows/#windows-version), but we need RS5 (17655+ build) for the containerd integration to work. appveyor supports it https://www.appveyor.com/docs/windows-images-software/#visual-studio-2019.

Note that this PR leaves all windows implementation empty. I have a local version which makes it work, I'll send out it one by one for easy reviewing and testing.

The first commit includes #1259.

@Random-Liu Random-Liu closed this Sep 2, 2019
@Random-Liu Random-Liu reopened this Sep 2, 2019
@Random-Liu Random-Liu force-pushed the windows-support-1 branch 11 times, most recently from ab036cc to 60f460d Compare September 3, 2019 05:53
@Random-Liu Random-Liu changed the title [WIP] Windows support 1 Build CRI Plugin on Windows and Add Presubmit Sep 3, 2019
@Random-Liu Random-Liu added this to the v1.4 milestone Sep 3, 2019
@Random-Liu Random-Liu force-pushed the windows-support-1 branch 4 times, most recently from 11ccfa2 to a604e24 Compare September 3, 2019 07:58
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

not sure how to review, it looks from this one (main) commit that we're forking most of the tree for things that might have some differences and setting the windows version of the fork to ... not implemented for now. Concerned that having two mostly different versions of the tree will make it harder to support the product. For example, you'll need to read both container_create_windows and container_create_unix before knowing how to modify either, and will have to test both independently, vs being able to just ignore simple path differences or sections of the code that say something like unix only or windows only.

PATH: C:\go\bin;C:\tools\mingw64\bin;$(PATH)
CGO_ENABLED: 1
matrix:
- GO_VERSION: 1.12.9
Copy link
Member

Choose a reason for hiding this comment

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

has to be hard coded to 1.12.9? this appveyor test is going to be a pain isn't it :)

Copy link
Member

Choose a reason for hiding this comment

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

other than the hard coding of the go version this presubmit test LGTM

Copy link
Member Author

Choose a reason for hiding this comment

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

Hard coded because of this containerd/containerd#3541


// DefaultConfig returns default configurations of cri plugin.
func DefaultConfig() PluginConfig {
return PluginConfig{}
Copy link
Member

Choose a reason for hiding this comment

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

i was only expecting the paths to be different for the most part in things like configs... which would require a two different sets of paths approach based on windows/linux ... not two copies of config. For example, StreamServerAddress: "127.0.0.1", local host the same on windows? As another example, sandbox image, is it multi arch? If so should be the same image. Still another, docker registry should be the same right?

Put another way... are we just forking entire sets of functions if there might be a difference of one path or one feature in a function, or are we forking because we know it will be very unique and no simple separation of paths and tools used could be determined. What's the plan?

Copy link
Contributor

Choose a reason for hiding this comment

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

It works in place :). Mostly haha. @Random-Liu - Should you fill this out with the defaults that matter from our fork for the checkin or do you want to do that as a followup?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mikebrow Here is the diff:

< // +build !windows
---
> // +build windows
30,32c30,32
< 			NetworkPluginBinDir:       "/opt/cni/bin",
< 			NetworkPluginConfDir:      "/etc/cni/net.d",
< 			NetworkPluginMaxConfNum:   1, // only one CNI plugin config file will be loaded
---
> 			NetworkPluginBinDir:       "C:\\Program Files\\containerd\\cni\\bin",
> 			NetworkPluginConfDir:      "C:\\Program Files\\containerd\\cni\\conf",
> 			NetworkPluginMaxConfNum:   1,
37c37
< 			DefaultRuntimeName: "runc",
---
> 			DefaultRuntimeName: "runhcs",
40,41c40,41
< 				"runc": {
< 					Type: "io.containerd.runc.v1",
---
> 				"runhcs": {
> 					Type: "io.containerd.runhcs.v1",
49d48
< 		EnableSelinux:       false,
55c54
< 		SandboxImage:            "k8s.gcr.io/pause:3.1",
---
> 		SandboxImage:            "mcr.microsoft.com/k8s/core/pause:1.0.0",
57d55
< 		SystemdCgroup:           false,
67d64
< 		DisableProcMount:       false,

Let's see whether we can further clean this up as part of #1245.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@Random-Liu - Knowing there is a future here can we not add "runhcs" and use "runhcs-wcow-process". It makes more sense and is more descriptive once the other two: "runhcs-wcow-hypervisor" and "runhcs-lcow" are added

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Will do in the next PR when actually adding the default config.

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

vendor commit LGTM

package main

import (
_ "github.com/containerd/containerd/diff/lcow"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with this but since you are only doing WCOW process for the first round we dont need any lcow/ stuff

Copy link
Member Author

@Random-Liu Random-Liu Sep 3, 2019

Choose a reason for hiding this comment

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

The problem is that the lcow differ is required here. https://github.com/containerd/containerd/blob/4e6e61c44e83ba1f69aa37ea603a9f23383821fb/services/diff/service_windows.go#L22

Can we add a no_windows-lcow build tag in containerd?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh funny. No problem just leave it. I dont think its worth the tag it wont work here anyways

pkg/os/os.go Outdated Show resolved Hide resolved
@@ -25,6 +25,8 @@ import (

// ContainerStats returns stats of the container. If the container does not
// exist, the call returns an error.
// TODO(windows): hcsshim Stats is not implemented, add windows support after
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I have a PR for you. Will link you in

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I'll file an issue after my next PR, and will add the support once the hcsshim side is ready. :)

@@ -51,46 +49,24 @@ const (
errorStartReason = "StartError"
// errorStartExitCode is the exit code when fails to start container.
// 128 is the same with Docker's behavior.
// TODO(windows): Figure out what should be used for windows.
errorStartExitCode = 128
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for "command not exist"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Usually this is caused by command not found.

See this https://github.com/moby/moby/blob/master/daemon/start.go#L127

@@ -443,6 +340,7 @@ func getRuntimeOptions(c containers.Container) (interface{}, error) {

const (
// unknownExitCode is the exit code when exit reason is unknown.
// TODO(windows): Figure out unknown exit status for windows.
unknownExitCode = 255
Copy link
Contributor

Choose a reason for hiding this comment

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

Runtime V2 defined this as 255 so we return that for Windows as well

Copy link
Member Author

@Random-Liu Random-Liu Sep 3, 2019

Choose a reason for hiding this comment

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

Nice. Sound good.

Removed the TODO.

Copy link
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

Nice! Minor questions

@Random-Liu
Copy link
Member Author

not sure how to review, it looks from this one (main) commit that we're forking most of the tree for things that might have some differences and setting the windows version of the fork to ... not implemented for now. Concerned that having two mostly different versions of the tree will make it harder to support the product. For example, you'll need to read both container_create_windows and container_create_unix before knowing how to modify either, and will have to test both independently, vs being able to just ignore simple path differences or sections of the code that say something like unix only or windows only

@mikebrow I share the same concern. Actually I've done a round of de-duplication. I think we've reduced to a reasonable amount of duplication. :)

I'll send out the actual windows implementation soon. If we still think that some part can be de-duplicated, we can cleanup after that is done.

Copy link
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

LGTM

@Random-Liu Random-Liu force-pushed the windows-support-1 branch 2 times, most recently from 619c35f to 6b3c705 Compare September 3, 2019 22:42
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM

@Random-Liu
Copy link
Member Author

Apply LGTM based on #1258 (review) and #1258 (review)

@Random-Liu Random-Liu added the lgtm label Sep 3, 2019
Signed-off-by: Lantao Liu <lantaol@google.com>
Signed-off-by: Lantao Liu <lantaol@google.com>
Signed-off-by: Lantao Liu <lantaol@google.com>
@k8s-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Sep 3, 2019
@Random-Liu
Copy link
Member Author

Did a rebase. Apply LGTM based on #1258 (review) and #1258 (review)

@Random-Liu Random-Liu added the lgtm label Sep 3, 2019
@Random-Liu Random-Liu merged commit 857a2d0 into containerd:master Sep 3, 2019
@Random-Liu Random-Liu deleted the windows-support-1 branch September 3, 2019 23:51
@yujuhong
Copy link
Member

yujuhong commented Sep 4, 2019

Late to the party, but lgtm :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants