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

Move runtime details into ContainerRuntime #64611

Merged
merged 2 commits into from Jul 16, 2018

Conversation

@bart0sh
Copy link
Contributor

bart0sh commented Jun 1, 2018

What this PR does / why we need it:

This PR moves all docker and CRI specifics into new ContainerRuntime
entity to isolate container runtime details from the rest of the code.

This should help to avoid having CRI and docker specific checks and code all over the place.

NOTE: this is a not a finished work, but rather an RFC.

Things to do:

  • test manually in docker and cri-o environments

Release note:

NONE
@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jun 1, 2018

/assign @kad

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jun 1, 2018

/cc chuckha

@k8s-ci-robot k8s-ci-robot requested a review from chuckha Jun 1, 2018

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jun 1, 2018

@k8s-ci-robot k8s-ci-robot requested a review from MikeSpreitzer Jun 1, 2018

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jun 1, 2018

/cc dixudx

@k8s-ci-robot k8s-ci-robot requested a review from dixudx Jun 1, 2018

@kad
Copy link
Member

kad left a comment

@bart0sh please add tests

/ok-to-test
/cc @luxas @timothysc @fabriziopandini

@@ -384,22 +384,22 @@ func NewCmdConfigImagesPull() *cobra.Command {

// ImagesPull is the struct used to hold information relating to image pulling
type ImagesPull struct {
puller images.Puller
images []string
cruntime *kubeadmutil.ContainerRuntime

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

I'd rather call this kind of variables runtime or containerRuntime.

glog.Errorln("[reset] failed to stop the running containers")
}
func removeContainers(execer utilsexec.Interface, criSocketPath string) {
cRuntime, err := kubeadmutil.NewContainerRuntime(execer, criSocketPath)

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

same here, for readability of code, better containerRuntime

@@ -12,6 +12,7 @@ go_library(
"arguments.go",
"cgroupdriver.go",
"copy.go",
"cruntime.go",

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

I think better to call it just runtime.go


// ContainerRuntime is a struct that interfaces with the container runtime
type ContainerRuntime struct {
rtype ContainerRuntimeType

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

runtimeType ?

if err == nil {
err = cruntime.Run("rmp", container)
}
} else {

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

better to do here switch with cruntime.rtype == CRI', cruntime.rtype == Dockeranddefaults:` with error.

if cruntime.rtype == CRI {
return cruntime.Run("inspecti", image)
}
return cruntime.Run("inspect", image)

This comment has been minimized.

@kad

kad Jun 1, 2018

Member

same here. use switch with known runtimes and defaults: if runtime is unknown.

@kad

This comment has been minimized.

Copy link
Member

kad commented Jun 1, 2018

/ok-to-test

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch from 6f7b260 to db54129 Jun 1, 2018

@k8s-ci-robot k8s-ci-robot added size/XXL and removed size/XL labels Jun 1, 2018

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch from db54129 to 8eaaba0 Jun 1, 2018

@k8s-ci-robot k8s-ci-robot added size/XL and removed size/XXL labels Jun 1, 2018

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jun 1, 2018

@kad thank you for the review. Updated the code as you've suggested.

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch from 8eaaba0 to 816ffe2 Jun 1, 2018

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch 2 times, most recently from 8cf2876 to f39d9cd Jul 9, 2018

@timothysc
Copy link
Member

timothysc left a comment

/approve

will let others who have been on this thread lgtm.

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch from f39d9cd to 636117a Jul 16, 2018

bart0sh added some commits May 31, 2018

move runtime details into ContainerRuntime
Created ContainerRuntime and used it in preflight checks,
'reset' and 'image' modules.
add test cases for kubeadm/app/util/runtime
covered ContainerRuntime API with test cases

@bart0sh bart0sh force-pushed the bart0sh:PR0017-kubeadm-create-Container-Runtime branch from 636117a to e0dd6cc Jul 16, 2018

@neolit123

This comment has been minimized.

Copy link
Member

neolit123 commented Jul 16, 2018

@bart0sh

hi, please have a look at this failing CI test:
https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/64611/pull-kubernetes-verify/98814/

it just needs a small formatting fix.

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jul 16, 2018

/test pull-kubernetes-e2e-kops-aws

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jul 16, 2018

/test pull-kubernetes-verify

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jul 16, 2018

/test pull-kubernetes-e2e-kops-aws

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jul 16, 2018

hm, it's approved, but still not merged. i guess it still requires lgtm. Can anybody help?

@neolit123

This comment has been minimized.

Copy link
Member

neolit123 commented Jul 16, 2018

thank you @bart0sh , seems good to me.
waiting on @luxas for the final LGTM.

@chuckha
Copy link
Member

chuckha left a comment

If you wrap all the tests in a t.Run() this lgtm

{execLookPathErr, "unix:///var/run/crio/crio.sock", false, true},
}

for _, tc := range cases {

This comment has been minimized.

@chuckha

chuckha Jul 16, 2018

Member

Best practice here is to run each test case in a sub test. https://golang.org/pkg/testing/#T.Run

The output is much nicer and we know exactly which test case is failing. Right now the output would be confusing and we wouldn't know which of the test cases were failing.

@luxas

luxas approved these changes Jul 16, 2018

Copy link
Member

luxas left a comment

/lgtm
Based on both me not spotting anything strange and @chuckha's review. If you can fix the unit tests to use subtests before the merge, fine, if not just follow-up. But I want to get this in now. We don't use subtests in ~90% of the other unit tests yet either so...

@k8s-ci-robot k8s-ci-robot added the lgtm label Jul 16, 2018

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Jul 16, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bart0sh, luxas, timothysc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fejta-bot

This comment has been minimized.

Copy link

fejta-bot commented Jul 16, 2018

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@bart0sh

This comment has been minimized.

Copy link
Contributor Author

bart0sh commented Jul 16, 2018

/retest

@k8s-github-robot

This comment has been minimized.

Copy link
Contributor

k8s-github-robot commented Jul 16, 2018

/test all [submit-queue is verifying that this PR is safe to merge]

@neolit123

This comment has been minimized.

Copy link
Member

neolit123 commented Jul 16, 2018

/test pull-kubernetes-integration

@k8s-github-robot

This comment has been minimized.

Copy link
Contributor

k8s-github-robot commented Jul 16, 2018

Automatic merge from submit-queue (batch tested with PRs 65429, 64611). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit ac4715d into kubernetes:master Jul 16, 2018

9 of 17 checks passed

Submit Queue Required Github CI test is not green: pull-kubernetes-e2e-gce
Details
pull-kubernetes-e2e-gce Job triggered.
Details
pull-kubernetes-e2e-gce-100-performance Job triggered.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job triggered.
Details
pull-kubernetes-e2e-kops-aws Job triggered.
Details
pull-kubernetes-integration Job triggered.
Details
pull-kubernetes-kubemark-e2e-gce-big Job triggered.
Details
pull-kubernetes-verify Job triggered.
Details
cla/linuxfoundation bart0sh authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gke Skipped
pull-kubernetes-local-e2e Skipped
pull-kubernetes-local-e2e-containerized Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details

k8s-github-robot pushed a commit that referenced this pull request Jul 20, 2018

Kubernetes Submit Queue
Merge pull request #66278 from bart0sh/PR0021-kubeadm-wrap-tests-in-T…
….Run

Automatic merge from submit-queue (batch tested with PRs 66152, 66406, 66218, 66278, 65660). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubeadm: wrap runtime tests in a t.Run

**What this PR does / why we need it**:

Improved runtime tests by using [T.Run API](https://golang.org/pkg/testing/#T.Run) 

This should improve testing output and make it more visible
which test is doing what.

**Which issue(s) this PR fixes**:

This PR addresses [this review comment](#64611 (review)) 

**Release note**:
```release-note
NONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.