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: extend cri apis for special needs #1617

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

starnop
Copy link
Contributor

@starnop starnop commented Jul 3, 2018

Signed-off-by: Starnop starnop@163.com

Ⅰ. Describe what this PR did

At present, the CRI interface of Kubernetes cannot meet the customized development of Kubelet. Therefore, it is necessary to provide the required functions of Kubelet by extending CRI.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Jul 3, 2018

Codecov Report

Merging #1617 into master will decrease coverage by 27.79%.
The diff coverage is 88.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1617      +/-   ##
==========================================
- Coverage   41.92%   14.13%   -27.8%     
==========================================
  Files         279      281       +2     
  Lines       18185    56755   +38570     
==========================================
+ Hits         7624     8021     +397     
- Misses       9638    47809   +38171     
- Partials      923      925       +2
Impacted Files Coverage Δ
cri/v1alpha2/cri_types.go 0% <ø> (ø) ⬆️
cri/v1alpha1/cri_types.go 0% <ø> (ø) ⬆️
cri/apis/v1alpha2/api.pb.go 0.57% <ø> (ø)
cri/apis/v1alpha1/api.pb.go 0.56% <ø> (ø)
daemon/containerio/cri_log_file.go 11.76% <ø> (ø) ⬆️
cri/v1alpha1/server.go 0% <ø> (ø) ⬆️
cri/v1alpha2/server.go 0% <ø> (ø) ⬆️
cri/v1alpha2/cri_network.go 0% <ø> (ø) ⬆️
cri/v1alpha2/service/cri.go 0% <ø> (ø) ⬆️
cri/v1alpha1/service/cri.go 0% <ø> (ø) ⬆️
... and 11 more

@@ -0,0 +1,1281 @@
// To regenerate api.pb.go run hack/update-generated-runtime.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

cri/apis/cri/v1alpha1 ---> cri/apis/v1alpha1
cri/apis/cri/runtime/v1alpha2 ---> cri/apis/v1alpha2

make the directory structure more clear

},
HostConfig: &apitypes.HostConfig{
Binds: generateMountBindings(config.GetMounts()),
Binds: generateMountBindings(config.GetMounts()),
Resources: parseResourceFromAPI(resources),
Copy link
Contributor

Choose a reason for hiding this comment

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

rename parseResourceFromAPI to parseResourcesFromAPI may more consistent :)

if runtimeUlimit == nil {
return nil
}
var ulimit []*apitypes.Ulimit
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make sure how to use slice in golang.

@starnop starnop force-pushed the cri-apiextend branch 4 times, most recently from 46a34b4 to bacfb54 Compare July 4, 2018 08:26
@pouchrobot
Copy link
Collaborator

ping @starnop
We found that this PR is 14 commits, which is more than 10 commits, behind master.
Please rebase the branch against master and push it back again. Thanks a lot.

@starnop starnop force-pushed the cri-apiextend branch 3 times, most recently from f6ec45b to fd9da28 Compare July 12, 2018 07:06
@@ -1,5 +1,5 @@
/*
Copyright 2017 The Kubernetes Authors.
Copyright YEAR AUTHORS.
Copy link
Contributor

Choose a reason for hiding this comment

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

YEAR AUTHORS?

// CRI extension related tool functions.

// parseResourceFromAPI parse Resources from runtime.LinuxContainerResources to apitypes.Resources
func parseResourcesFromAPI(runtimeResources *runtime.LinuxContainerResources) apitypes.Resources {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/parseResoucesFromAPI/pbLinuxContainerResourcesToAPIResouces/g WDYT?

func parseVolumesFromPouch(containerVolumes map[string]interface{}) map[string]*runtime.Volume {
volumes := make(map[string]*runtime.Volume)
for k, v := range containerVolumes {
volumes[k] = v.(*runtime.Volume)
Copy link
Contributor

@fuweid fuweid Jul 12, 2018

Choose a reason for hiding this comment

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

always (*runtime.Volume) ? nil or other type?

Could we use two-values assertion to get the value? if fails, log it or return error

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. thanks for your comment.

@starnop starnop force-pushed the cri-apiextend branch 4 times, most recently from baa10e9 to 58412d3 Compare July 12, 2018 10:13
@@ -728,7 +734,9 @@ func (c *CriManager) ContainerStatus(ctx context.Context, r *runtime.ContainerSt
Message: message,
Labels: labels,
Annotations: annotations,
// TODO: LogPath.
LogPath: container.LogPath,
Copy link
Contributor

Choose a reason for hiding this comment

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

The container.LogPath is not the log path of cri container

I'll fix it in my next PR, please leave it empty now :)

@starnop starnop force-pushed the cri-apiextend branch 8 times, most recently from a624b1d to ccd77d4 Compare July 16, 2018 06:18
hack/protoc.sh Outdated
}

main(){
generateproto
Copy link
Contributor

Choose a reason for hiding this comment

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

API_ROOT="${DIR}/cri/apis/v1alpha1" generateproto
API_ROOT="${DIR}/cri/apis/v1alpha2" generateproto

@starnop starnop force-pushed the cri-apiextend branch 3 times, most recently from deefe75 to 9dbcbec Compare July 16, 2018 07:50
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

Signed-off-by: Starnop <starnop@163.com>
@YaoZengzeng
Copy link
Contributor

I've used this PR to do node-e2e test, it works fine.

LGTM

@allencloud allencloud merged commit 165899c into AliyunContainerService:master Jul 16, 2018
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.

6 participants