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

Containerized mount utilities #53440

Merged
merged 3 commits into from
Nov 14, 2017

Conversation

jsafrane
Copy link
Member

@jsafrane jsafrane commented Oct 4, 2017

This is implementation of kubernetes/community#589

@tallclair @vishh @dchen1107 PTAL
@kubernetes/sig-node-pr-reviews

Release note:

Kubelet supports running mount utilities and final mount in a container instead running them on the host.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 4, 2017
@ianchakeres
Copy link
Contributor

/sig storage

@k8s-ci-robot k8s-ci-robot added the sig/storage Categorizes an issue or PR as relevant to SIG Storage. label Oct 5, 2017
@cblecker
Copy link
Member

cblecker commented Oct 5, 2017

Needs a hack/update-bazel.sh:

I1004 16:23:28.818] Verifying hack/make-rules/../../hack/verify-bazel.sh
I1004 16:23:49.573] --- /go/src/k8s.io/kubernetes/pkg/kubelet/mountpod/BUILD	2017-10-04 16:17:57.518523051 +0000
I1004 16:23:49.574] +++ /tmp/BUILD245520658	2017-10-04 16:23:38.822525349 +0000
I1004 16:23:49.574] @@ -6,7 +6,6 @@
I1004 16:23:49.574]      visibility = ["//visibility:public"],
I1004 16:23:49.574]      deps = [
I1004 16:23:49.574]          "//pkg/kubelet/pod:go_default_library",
I1004 16:23:49.574] -        "//vendor/github.com/golang/glog:go_default_library",
I1004 16:23:49.574]          "//vendor/k8s.io/api/core/v1:go_default_library",
I1004 16:23:49.574]      ],
I1004 16:23:49.575]  )
I1004 16:23:49.575] 
I1004 16:23:49.575] 
I1004 16:23:49.575] Run ./hack/update-bazel.sh
I1004 16:23:49.615] FAILED   hack/make-rules/../../hack/verify-bazel.sh	21s

@mtaufen mtaufen assigned saad-ali and jingxu97 and unassigned mtaufen Oct 9, 2017
Copy link
Member

@tallclair tallclair left a comment

Choose a reason for hiding this comment

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

No big issues.

PodName string
PodNamespace string
PodUID string
ContainerName string
Copy link
Member

Choose a reason for hiding this comment

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

nit: in the proposal, field names are lowercase in json. I think you need json tags to match.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added json tags

return path.Join(m.registrationDirectory, safePluginName)
}

func (m *basicManager) GetMountPod(pluginName string) (*v1.Pod, string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Name return values (i.e. what is the string?)

Copy link
Member Author

Choose a reason for hiding this comment

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

added

if !ok {
return nil, "", fmt.Errorf("unable to process %s: pod %s/%s not found", regPath, reg.PodNamespace, reg.PodName)
}
if string(pod.UID) != reg.PodUID {
Copy link
Member

Choose a reason for hiding this comment

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

I think this will be OK, but double check that this works with static/mirror pods.

Copy link
Member Author

Choose a reason for hiding this comment

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

Static pod gets a different UID via dawnward API than it's in the API server :-(

Can we require that pods with mount utilities are not static?

Copy link
Member Author

Choose a reason for hiding this comment

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

Scratch the previous comment. Pod indeed gets different UID via downward API than it's in the API server, however kubelet sees the right ("downward") UID in this check and everything works.

output, err := m.exec.Run("mount", mountArgs...)
glog.V(5).Infof("Exec mounted %v: %v: %s", mountArgs, err, string(output))
if err != nil {
glog.Errorf("Mount failed: %v\nMounting command: %s\nMounting arguments: %s %s %s %v\nOutput: %s\n", err, "mount", source, target, fstype, options, string(output))
Copy link
Member

Choose a reason for hiding this comment

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

nit: errors shouldn't be logged if they're also propagated

Copy link
Member Author

Choose a reason for hiding this comment

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

log removed

outputBytes, err := m.exec.Run("umount", target)
glog.V(5).Infof("Exec unmounted %v: %s", err, string(outputBytes))
if len(outputBytes) != 0 {
glog.V(5).Infof("Output of unmounting %s: %v", target, string(outputBytes))
Copy link
Member

Choose a reason for hiding this comment

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

combine this with the above log message

Copy link
Member Author

Choose a reason for hiding this comment

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

reworked a bit to have higher log level on error

@jsafrane jsafrane force-pushed the mount-container4-10-03 branch 2 times, most recently from 2d93066 to ff9dd61 Compare October 19, 2017 12:57
@jsafrane
Copy link
Member Author

Polished the PR a bit, namely introduced DefaultKubeletPluginContainersDirName in pkg/kubelet/config/defaults.go to keep directory names together.

@jsafrane
Copy link
Member Author

/assign @tallclair
is there anything missing?

k8s-github-robot pushed a commit that referenced this pull request Oct 27, 2017
Automatic merge from submit-queue (batch tested with PRs 54635, 54250, 54657, 54696, 54700). 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>.

Don't cache exec and mounter in RBD volume plugin

#51608 has broken containerized RBD mount utilities proposed in #53440.

Volume plugin can get a different exec and mounter implementation with every call, it must not be cached.

```release-note
NONE
```

/sig storage
/assign @rootfs
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 29, 2017
@jsafrane
Copy link
Member Author

jsafrane commented Nov 2, 2017

Rebased
@tallclair, PTAL.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2017
@tallclair
Copy link
Member

Looks good, just a couple nits.

for i := range pod.Spec.Containers {
if pod.Spec.Containers[i].Name == reg.ContainerName {
found = true
break
Copy link
Member

Choose a reason for hiding this comment

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

nit: just return here, and get rid of found

Copy link
Member Author

Choose a reason for hiding this comment

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

done

return mount.NewOsExec()
exec, err := kvh.getMountExec(pluginName)
if err != nil {
glog.V(2).Info(err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

nit: give this a little context

Copy link
Member Author

Choose a reason for hiding this comment

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

Added context:
Error finding mount pod for plugin %s: %s", pluginName, err.Error()

return kvh.kubelet.mounter
exec, err := kvh.getMountExec(pluginName)
if err != nil {
glog.V(2).Info(err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

nit: error context

Copy link
Member Author

Choose a reason for hiding this comment

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

Added context:
Error finding mount pod for plugin %s: %s", pluginName, err.Error()

@jsafrane
Copy link
Member Author

rebased + fixed review remarks
@tallclair, PTAL

@tallclair
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 10, 2017
@jsafrane
Copy link
Member Author

/assign @thockin
for approval, thanks in advance!

@thockin
Copy link
Member

thockin commented Nov 13, 2017

/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, tallclair, thockin

Associated issue requirement bypassed by: thockin

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 13, 2017
@k8s-github-robot
Copy link

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

exec Exec
}

func NewExecMounter(exec Exec, wrapped Interface) Interface {
Copy link
Member

Choose a reason for hiding this comment

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

Is it intentional that this does not touches SafeFormat portions of work?

Copy link
Member Author

Choose a reason for hiding this comment

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

SafeFormat is itself a wrapper over mount.Interface. It will work if it wraps ExecMounter instead of the generic Linux Mounter

@kfox1111
Copy link

Question... how was flex volume support done? Is it broken up into one container per plugin, or one for all flexvolumes?

@jsafrane
Copy link
Member Author

Flex is out of scope of this PR, at least in alpha. Flex has their own method of dynamic registration of drivers that could be used by flex driver running in a container. See https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/flexvolume-deployment.md

@kfox1111
Copy link

ok, thanks. I'll see if I can get that to work.

k8s-github-robot pushed a commit that referenced this pull request Mar 20, 2018
Automatic merge from submit-queue. 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>.

Fix test images

These commits fix volume_io tests for iSCSI and Ceph RBD. Both server images were quite old (Fedora 22), so I updated them to ~~something more stable (CentOS 7) and to newer Ceph (Jewel, 10.2.7).~~ something newer (Fedora 26).

The most important fix is that the test volumes have 120 MB so volume_io test can actually run - the tests put 100MB file to the volume to check its persistence.

When mount containers in #53440 are merged I'll try to run the tests regularly with every PR (or merge) so we catch regressions quickly.

```release-note
NONE
```

/sig testing
/sig storage

/assign @jeffvance 

Fixes: #56725
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. 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.