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

git: Use VolumeHost.GetExec() to execute stuff in volume plugins #51098

Merged
merged 1 commit into from Jan 11, 2018

Conversation

jsafrane
Copy link
Member

@jsafrane jsafrane commented Aug 22, 2017

This prepares volume plugins to run things in containers instead of running
them on the host.

Special notes for your reviewer:

  • instead of cmd.SetDir(<dir>); cmd.Exec("git <command>"), we do cmd.Exec("git -C <dir> <command>") - mounter.Exec does not have SetDir()
  • there are lot of changes in the tests because a different exec interface is used.

@kubernetes/sig-storage-pr-reviews

gitRepo volumes in pods require git 1.8.5 or later

/assign @rootfs

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 22, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Aug 22, 2017
@jsafrane
Copy link
Member Author

/sig storage

@jsafrane
Copy link
Member Author

/retest

var commandLog []expectedCommand
execCallback := func(cmd string, args ...string) ([]byte, error) {
// command is 'git -C <dir> <command> <args>
gitCommand := args[2]
Copy link
Contributor

Choose a reason for hiding this comment

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

error out if len(args) is invalid

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, fixed. Now I check that arg[0] == "-C", just to be sure.

}
// add the command to log with de-randomized gitDir
args[1] = strings.Replace(gitDir, mounter.GetPath(), "volume-dir", 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

based on the context, it should just return volume-dir right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it should always return "volume-dir". However, if there is bug in the volume plugin it may be called with a different directory and the test should catch it.

Copy link
Contributor

Choose a reason for hiding this comment

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

why not just force it: args[1] = "volume-dir", replace doesn't reset the entire 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.

Because I want to check that correct arg[1] was used by the plugin. If the plugin uses /var/lib/kubelet/pods/<uid>/kubernetes.io~git/foo/123 instead of correct ..kubernetes.io~git/foo/, Replace will return volume-plugin/123 and the test (correctly) fails.

@jsafrane
Copy link
Member Author

/retest

@jsafrane
Copy link
Member Author

/test all

@jsafrane
Copy link
Member Author

@rootfs not sure where we are with this, can it be merged?

@rootfs
Copy link
Contributor

rootfs commented Aug 30, 2017

/approve no-issue
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 30, 2017
@rootfs
Copy link
Contributor

rootfs commented Aug 30, 2017

/retest

@fejta-bot
Copy link

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

Review the full test history for this PR.

2 similar comments
@fejta-bot
Copy link

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

Review the full test history for this PR.

@fejta-bot
Copy link

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

Review the full test history for this PR.

@jsafrane
Copy link
Member Author

/retest

3 similar comments
@jsafrane
Copy link
Member Author

/retest

@jsafrane
Copy link
Member Author

/retest

@jsafrane
Copy link
Member Author

/retest

This prepares volume plugins to run things in containers instead of running
them on the host.
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2017
@jsafrane
Copy link
Member Author

Fixed e2e tests (luckily we have them): I forgot to fill exec here: https://github.com/kubernetes/kubernetes/pull/51098/files#diff-45aabca84f5daab0bb5d8194a7282018R104

Which led to panic when exec was actually used here: https://github.com/kubernetes/kubernetes/pull/51098/files#diff-45aabca84f5daab0bb5d8194a7282018R250

@rootfs PTAL

@rootfs
Copy link
Contributor

rootfs commented Aug 31, 2017

/test pull-kubernetes-e2e-gce-etcd3

@rootfs
Copy link
Contributor

rootfs commented Aug 31, 2017

/test pull-kubernetes-e2e-gce-bazel

@jsafrane
Copy link
Member Author

UTC (durationBeforeRetry 500ms). Error: MountVolume.SetUp failed for volume "git-volume" (UniqueName: "kubernetes.io/git-repo/7b075d4e-8e4c-11e7-bd35-42010a800002-git-volume") pod "pod-secrets-7b0481e5-8e4c-11e7-a485-0a580a3c456b" (UID: "7b075d4e-8e4c-11e7-bd35-42010a800002") : failed to exec 'git clone http://10.0.32.88:2345 test':
Unknown option: -C
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]
: exit status 129

Damn

@jsafrane
Copy link
Member Author

jsafrane commented Sep 1, 2017

The best way out of this is to add exec.SetDir(), just like util/exec does. But this cannot be easily implemented either in controller manager that will need to execute attach/detach utils via something like kubectl exec or in kubeler where CRI does not allow specification of working directory.

And I do not know about any smart way how to run sh -c "cd <dir>; git <args>" that would prevent shell from interpreting characters like `, $, ", ', ; and so on - part of args comes from user and must not be interpreted by shell and escaping these is dangerous.

@rootfs, any idea?

@rootfs
Copy link
Contributor

rootfs commented Oct 2, 2017

/keep-open

@jsafrane
Copy link
Member Author

/retest
(to see if the tests moved from Wheezy to GCI)

@jsafrane
Copy link
Member Author

/test e2e-gce

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 2, 2017
@jsafrane
Copy link
Member Author

jsafrane commented Nov 2, 2017

@rootfs, it seems that the test env. was updated and we can merge this PR. I added a release note to use newer git.

@rootfs
Copy link
Contributor

rootfs commented Dec 4, 2017

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, rootfs

Associated issue requirement bypassed by: rootfs

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

@jsafrane
Copy link
Member Author

/test all

@jsafrane
Copy link
Member Author

/test kubernetes-cross

@jsafrane
Copy link
Member Author

/test pull-kubernetes-cross

@k8s-github-robot
Copy link

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

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 820ea04 into kubernetes:master Jan 11, 2018
k8s-github-robot pushed a commit that referenced this pull request Apr 13, 2018
Automatic merge from submit-queue (batch tested with PRs 60476, 62462, 61391, 62535, 62394). 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>.

Revert "git: Use VolumeHost.GetExec() to execute stuff in volume plugins"

This reverts commit c578542 (PR #51098). The PR added support for containerized git, on the other hand it required git 1.8.5. This breaks git volumes on older distros (CentOS 7, Ubuntu 14.04) that have old git.

Git volumes are getting deprecated (#60999) so we should restore it to the last working state and not touch it any longer.

**Release note**:

```release-note
gitRepo volumes in pods no longer require git 1.8.5 or newer, older git versions are supported too now.
```

I'd like to cherry-pick it into 1.10.

/sig storage
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/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants