Skip to content

cp exec util from kubernetes/kubernetes #5

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

Merged
merged 28 commits into from
Jul 19, 2017

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Jul 7, 2017

No description provided.

thockin and others added 24 commits October 6, 2014 16:52
Use %v for errors, tidy some messages, make error messages start lowe-case
(as per go guidelines).  Just accumulated nits.
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
Also add Output() to the util/exec Cmd interface.
- improve restoreInternal implementation in iptables
- add SetStdin and SetStdout functions to Cmd interface
- modify kubelet/prober and some tests in order to work with Cmd interface
Add canonical imports only in existing doc.go files.
https://golang.org/doc/go1.4#canonicalimports

Fixes #29014
Automatic merge from submit-queue

improve iptables-restore implementation #27559

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
fixes #27559
- improve restoreInternal implementation in iptables
- add SetStdin and SetStdout functions to Cmd interface
- modify kubelet/prober and some tests in order to work with Cmd interface
`ex.Command()` already searches the binary in PATH, no need to manually
specify it. `pkg/util/exec` tests fail in non-conventional environments
due to this (e.g. NixOS).
@mengqiy
Copy link
Member Author

mengqiy commented Jul 7, 2017

Travis finally works.

exec/doc.go Outdated
@@ -0,0 +1,18 @@
/*
Copyright 201i7 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Did you make that typo?

Copy link
Member

Choose a reason for hiding this comment

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

We need to be able to verify license in files :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

How?

Copy link
Member

Choose a reason for hiding this comment

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 7, 2017
@apelisse
Copy link
Member

@spxtr any clue?

@spxtr spxtr closed this Jul 14, 2017
@spxtr spxtr reopened this Jul 14, 2017
@spxtr
Copy link

spxtr commented Jul 14, 2017

The CLA won't pass since this includes commits made before we switched to CNCF CLA. That's fine, merge over it.

@spxtr
Copy link

spxtr commented Jul 14, 2017

Not sure why travis isn't responding.

@apelisse
Copy link
Member

It's running!

@apelisse
Copy link
Member

Yay, now we know it's broken ;-)

@mengqiy
Copy link
Member Author

mengqiy commented Jul 18, 2017

It was broken because I move fake_exec.go to test/. Now it has been fixed. It's passing now :)

@mengqiy mengqiy mentioned this pull request Jul 18, 2017
4 tasks
@mengqiy
Copy link
Member Author

mengqiy commented Jul 18, 2017

We need to wait till this PR get merged first.
Then we can send a PR in the main repo to update the vendor directory.

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

Thanks Mengqi!

limitations under the License.
*/

package exec
Copy link
Member

Choose a reason for hiding this comment

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

Should this be named package exec even though it's actually in exec/testing/?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to testingexec.


// Wraps exec.Cmd so we can capture errors.
type cmdWrapper osexec.Cmd

Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to add

var _ Cmd = &cmdWrapper{}

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. It's good to have a check to make sure it has implemented the interface.
Also add the check in testing/fake_exec.go. Does it make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think it does. I didn't mention it because func InitFakeCmd(fake *FakeCmd, cmd string, args ...string) exec.Cmd would fail if fake wasn't a exec.Cmd, but that's probably more subtle that necessary. Thanks for the changes!

exec/exec.go Outdated
// ErrExecutableNotFound is returned if the executable is not found.
var ErrExecutableNotFound = osexec.ErrNotFound

// Interface is an interface that presents a subset of the os/exec API. Use this
Copy link
Member

Choose a reason for hiding this comment

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

Very dumb nit: double space after period

exec/exec.go Outdated
}

// Cmd is an interface that presents an API that is very similar to Cmd from os/exec.
// As more functionality is needed, this can grow. Since Cmd is a struct, we will have
Copy link
Member

Choose a reason for hiding this comment

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

Very dumb nit: double space after period

exec/exec.go Outdated
// Run runs the command to the completion.
Run() error
// CombinedOutput runs the command and returns its combined standard output
// and standard error. This follows the pattern of package os/exec.
Copy link
Member

Choose a reason for hiding this comment

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

Very dumb nit: double space after period

exec/exec.go Outdated
}

// ExitError is an interface that presents an API similar to os.ProcessState, which is
// what ExitError from os/exec is. This is designed to make testing a bit easier and
Copy link
Member

Choose a reason for hiding this comment

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

Very dumb nit: double space after period

@mengqiy
Copy link
Member Author

mengqiy commented Jul 19, 2017

@apelisse PTAL
I will squash before merging.

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

lgtm!


// Wraps exec.Cmd so we can capture errors.
type cmdWrapper osexec.Cmd

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think it does. I didn't mention it because func InitFakeCmd(fake *FakeCmd, cmd string, args ...string) exec.Cmd would fail if fake wasn't a exec.Cmd, but that's probably more subtle that necessary. Thanks for the changes!

@apelisse apelisse merged commit 9fdc871 into kubernetes:master Jul 19, 2017
@apelisse
Copy link
Member

Forced the merge because of cla errors.

@mengqiy mengqiy deleted the util_exec branch July 19, 2017 03:27
@mengqiy
Copy link
Member Author

mengqiy commented Jul 19, 2017

Associated PR against main repo: kubernetes/kubernetes#49234

k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Jul 20, 2017
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: kubernetes/utils#5

```release-note
NONE
```

/assign @apelisse
dims pushed a commit to dims/openstack-cloud-controller-manager that referenced this pull request Sep 6, 2017
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: kubernetes/utils#5

```release-note
NONE
```

/assign @apelisse
dims pushed a commit to dims/openstack-cloud-controller-manager that referenced this pull request Jan 13, 2018
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: kubernetes/utils#5

```release-note
NONE
```

/assign @apelisse
wgliang pushed a commit to wgliang/utils that referenced this pull request Jun 11, 2018
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: kubernetes#5

```release-note
NONE
```

/assign @apelisse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: no Indicates the PR's author has not signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.