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

feature: Update CRI from v1alpha1 to v1alpha2 & support down-level compatibility #1359

Merged
merged 1 commit into from
May 23, 2018

Conversation

starnop
Copy link
Contributor

@starnop starnop commented May 21, 2018

Basically, Pouch has not supported Kubernetes 1.10+ because of update CRI from v1alpha1 to v1alpha2.
Signed-off-by: Starnop [email protected]

Ⅰ. Describe what this PR did

Update CRI from v1alpha1 to v1alpha2 & support down-level compatibility

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Describe how you did it

  1. update package from cri/v1alpha1/runtime to cri/runtime/v1alpha2
  2. fix: convert GetHostNetwork() to GetNetwork(),etc
  3. add ReopenContainerLog function definition
  4. nothing should be configured when PidMode equals NamespaceMode_CONTAINER
  5. maintain two pieces of code at the same time.

Ⅳ. Describe how to verify it

  1. It has passed CRI validation tests.
  2. Deploying with released Kubernetes 1.5.+ will be successful.
  3. Use command
pouchd --enable-cri --cri-version v1alpha1/v1alpha2

to support CRI v1alpha1/v1alpha2

Ⅴ. Special notes for reviews

The doc will be updated in the back PR.
The function of ReopenContainerLog has not been implemented, I'll fix it in the back PR.

@codecov-io
Copy link

codecov-io commented May 21, 2018

Codecov Report

Merging #1359 into master will decrease coverage by 1%.
The diff coverage is 8.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1359      +/-   ##
==========================================
- Coverage   17.29%   16.29%   -1.01%     
==========================================
  Files         190      197       +7     
  Lines       11911    13387    +1476     
==========================================
+ Hits         2060     2181     +121     
- Misses       9703    11056    +1353     
- Partials      148      150       +2
Impacted Files Coverage Δ
cri/v1alpha1/cri_types.go 0% <ø> (ø)
cri/v1alpha1/cri_network.go 0% <ø> (ø)
cri/v1alpha1/cri_wrapper.go 0% <ø> (ø)
cri/v1alpha1/cri_utils.go 29.31% <ø> (ø)
cri/v1alpha1/cri.go 0% <ø> (ø)
cri/v1alpha2/cri_network.go 0% <0%> (ø)
cri/v1alpha2/cri_types.go 0% <0%> (ø)
cri/v1alpha2/cri_stream.go 0% <0%> (ø)
cri/v1alpha1/server.go 0% <0%> (ø)
cri/v1alpha1/cri_stream.go 0% <0%> (ø)
... and 21 more

@fuweid fuweid self-assigned this May 21, 2018
case "v1alpha1":
runv1alpha1(daemonconfig, containerMgr, imageMgr)
case "v1alpha2":
runv1alpha2(daemonconfig, containerMgr, imageMgr)
Copy link
Contributor

Choose a reason for hiding this comment

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

If user doesn't specify the CRI version, use "v1alpha2" by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll change it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If user doesn't specify the CRI version, use "v1alpha2" by default.

Yes, I think this is reasonable to set a default one. And throw out a line of related log.

@@ -5,7 +5,7 @@ import (
"path"

"github.com/alibaba/pouch/apis/plugins"
cri "github.com/alibaba/pouch/cri/src"
cri "github.com/alibaba/pouch/cri/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

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

GenCriMgr in this file is no longer needed.

return
}

func runv1alpha1(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Print a log here, like Start CRI services, version: v1alpha1(just an example, could be better?), which may be helpful in debugging.

The same for function runv1alpha2.

@@ -5,7 +5,7 @@ import (
"os"
"syscall"

cri "github.com/alibaba/pouch/cri/src"
cri "github.com/alibaba/pouch/cri/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

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

This directory could be deprecated as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@YaoZengzeng All mentioned above has been done.

@starnop starnop force-pushed the cri-upgrade branch 7 times, most recently from 7b8a2be to cfbce09 Compare May 21, 2018 09:36
@HusterWan HusterWan added this to the v0.5.0-milestone milestone May 21, 2018
@starnop starnop force-pushed the cri-upgrade branch 2 times, most recently from 3fcb71f to 4b148ec Compare May 22, 2018 01:46
}

func runv1alpha1(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr) {
logrus.Infof("Start CRI services with CRI version: v1alpha1")
Copy link
Contributor

Choose a reason for hiding this comment

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

CRI services -> CRI service, please be consistent with other places :)

}

func runv1alpha2(daemonconfig *config.Config, containerMgr mgr.ContainerMgr, imageMgr mgr.ImageMgr) {
logrus.Infof("Start CRI services with CRI version: v1alpha2")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@starnop starnop force-pushed the cri-upgrade branch 3 times, most recently from ac3fcd0 to 2e09bb7 Compare May 22, 2018 07:34
close(streamServerCloseCh)
}()

<-streamServerCloseCh
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 please create issue to track the thing that it is to make server close gracefully? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe with a TODO annotation ?

}

defer func() {
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the defer function work here, because it has finished if the err is not null.

if err != nil {
return 0, fmt.Errorf("failed to start exec for container %q: %v", containerID, err)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the todo/fixme as reminder. I think we can find the better way to handle this case gracefully instead of the dead loop. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fuweid All mentioned above has been done.

@fuweid
Copy link
Contributor

fuweid commented May 23, 2018

LGTM

@fuweid fuweid merged commit 0df5157 into AliyunContainerService:master May 23, 2018
HusterWan added a commit that referenced this pull request May 23, 2018
cherry-pick: cherry-pick #1359 from master to 0.5.x
@idealhack
Copy link
Contributor

Hi @starnop, may I ask a question?

Since vendor.json only have k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime now, not k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2, how do we want to manage these dependencies?

I think we may want to track the newer version, not the old one.

@starnop
Copy link
Contributor Author

starnop commented May 31, 2018

@idealhack I'm sorry for my negligence. I'll fix that, thank you!

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

Successfully merging this pull request may close these issues.

8 participants