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

rkt: rewrote GetPods to use rkt's api service #17969

Merged
merged 1 commit into from
Dec 11, 2015

Conversation

cgonyeo
Copy link
Contributor

@cgonyeo cgonyeo commented Nov 30, 2015

This commit modifies the kubelet to use rkt's new API service when the kubelet wants to list all current pods.

This involved adding annotations to the rkt pod's manifest that contain
information about the kubernetes pod, which is later read by the
kubelet.

@k8s-bot
Copy link

k8s-bot commented Nov 30, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

1 similar comment
@k8s-bot
Copy link

k8s-bot commented Nov 30, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

@yifan-gu
Copy link
Contributor

cc @dchen1107 @jonboulle

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 30, 2015
}
}

manifest.Annotations = append(manifest.Annotations, []appctypes.Annotation{
Copy link
Contributor

Choose a reason for hiding this comment

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

To be pedantic - you should check for any existing annotations by these names, since the spec says they must be unique:

Annotation names must be unique within the list.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jonboulle We should validate this when marshaling the manifest

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure but the behaviour is not going to be very user friendly in that case.

@yifan-gu
Copy link
Contributor

@dgonyeo I believe there should be other files in this PR right?

@cgonyeo
Copy link
Contributor Author

cgonyeo commented Nov 30, 2015

Not sure what files I'm missing here.

@yifan-gu
Copy link
Contributor

@dgonyeo I was thinking you have modified rkt_info stuff. Never mind.
Would be better we add a test for GetPods().

@thockin thockin assigned yujuhong and unassigned thockin Dec 1, 2015
@@ -71,6 +72,16 @@ const (
unitRktID = "RktID"
unitRestartCount = "RestartCount"

k8sRktKubeletAnno = "k8s.io/rkt/managed-by-kubelet"
k8sRktKubeletAnnoValue = "true"
k8sRktUIDAnno = "k8s.io/rkt/uid"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these are valid annotations. you want rkt.kubernetes.io/uid, etc

@cgonyeo cgonyeo force-pushed the rkt_api_get_pods branch 2 times, most recently from b2410fe to 8361f45 Compare December 1, 2015 21:26
if countString, ok := manifest.Annotations.Get(k8sRktRestartCountAnno); ok {
num, err := strconv.Atoi(countString)
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

print the error here?

Copy link
Contributor

Choose a reason for hiding this comment

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

besides, why continue here, but return error in other places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had a feeling that if I errored on that, that one could prevent the kubelet from restarting a given pod by inserting a pod with a matching uid annotation and a garbage restart count annotation.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dgonyeo OK, but that can also happen by inserting random bytes in the pod manifest to let json.Unmarshal fail?
I am ok we all continue in these places, with a warning message printed.

}

manifest := appcschema.PodManifest{}
err = json.Unmarshal(inspectResp.Pod.Manifest, manifest)
Copy link
Contributor

Choose a reason for hiding this comment

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

unmarshal needs a pointer

@cgonyeo cgonyeo force-pushed the rkt_api_get_pods branch 2 times, most recently from 259e69a to 6e39cd3 Compare December 4, 2015 19:16
@yujuhong
Copy link
Contributor

yujuhong commented Dec 4, 2015

Please run gofmt.

hack/verify-gofmt.sh
!!! 'gofmt -s' needs to be run on the following files: 
./pkg/kubelet/rkt/rkt.go
./pkg/kubelet/rkt/rkt_test.go
make: *** [verify] Error 1

@yifan-gu
Copy link
Contributor

yifan-gu commented Dec 5, 2015

@k8s-bot ok to test

@cgonyeo
Copy link
Contributor Author

cgonyeo commented Dec 9, 2015

@yifan-gu should be ready for another pass.

@k8s-github-robot
Copy link

Labelling this PR as size/XL

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 9, 2015
}, opts.PortMappings, nil
}

func getMatchingPodsRequest(pod *api.Pod) *rktapi.ListPodsRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably not the best name, how about just return the filter, and call it kubernetesPodFilter or something?

@yifan-gu
Copy link
Contributor

yifan-gu commented Dec 9, 2015

commented, just some small testing stuff. @dgonyeo

This involved adding annotations to the rkt pod's manifest that contain
information about the kubernetes pod, which is later read by the
kubelet.
@cgonyeo
Copy link
Contributor Author

cgonyeo commented Dec 9, 2015

Done. How's that look?

@yifan-gu
Copy link
Contributor

yifan-gu commented Dec 9, 2015

LGTM. I think we need to do some further reorganizing on the code later.
@yujuhong do you want to take a look at this before I add lgtm label?

@yujuhong yujuhong added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 10, 2015
@k8s-github-robot
Copy link

@k8s-bot ok to test
@k8s-bot test this

pr builder appears to be missing, activating due to 'lgtm' label.

@k8s-bot
Copy link

k8s-bot commented Dec 10, 2015

GCE e2e test build/test passed for commit 5a16b47.

@k8s-github-robot
Copy link

The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 10, 2015

GCE e2e test build/test passed for commit 5a16b47.

@yujuhong
Copy link
Contributor

@k8s-bot unit test this

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 11, 2015

GCE e2e test build/test passed for commit 5a16b47.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Dec 11, 2015
@k8s-github-robot k8s-github-robot merged commit 6b8eb90 into kubernetes:master Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants