Skip to content

cp exec util from kubernetes/kubernetes - #5

Merged
apelisse merged 28 commits into
kubernetes:masterfrom
mengqiy:util_exec
Jul 19, 2017
Merged

apelisse merged 28 commits into
kubernetes:masterfrom
mengqiy:util_exec

Conversation

@mengqiy

@mengqiy mengqiy commented Jul 7, 2017

Copy link
Copy Markdown
Member

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

mengqiy commented Jul 7, 2017

Copy link
Copy Markdown
Member Author

Travis finally works.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@spxtr spxtr closed this Jul 14, 2017
@spxtr spxtr reopened this Jul 14, 2017
@spxtr

spxtr commented Jul 14, 2017

Copy link
Copy Markdown

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

@spxtr

spxtr commented Jul 14, 2017

Copy link
Copy Markdown

Not sure why travis isn't responding.

@apelisse

Copy link
Copy Markdown
Member

It's running!

@apelisse

Copy link
Copy Markdown
Member

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

@mengqiy

mengqiy commented Jul 18, 2017

Copy link
Copy Markdown
Member Author

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
1 of 4 tasks
@mengqiy

mengqiy commented Jul 18, 2017

Copy link
Copy Markdown
Member Author

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.

@apelisse apelisse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Mengqi!

Comment thread exec/testing/fake_exec.go Outdated
limitations under the License.
*/

package exec

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread exec/exec.go

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

Comment thread 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
Copy Markdown
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

Comment thread 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
Copy Markdown
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

Comment thread 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
Copy Markdown
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

Comment thread 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
Copy Markdown
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

mengqiy commented Jul 19, 2017 •

Copy link
Copy Markdown
Member Author

@apelisse PTAL
I will squash before merging.

@apelisse apelisse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

Comment thread exec/exec.go

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

Copy link
Copy Markdown
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
Copy Markdown
Member

Forced the merge because of cla errors.

@mengqiy
mengqiy deleted the util_exec branch July 19, 2017 03:27
@mengqiy

mengqiy commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

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
mhan8796 pushed a commit to mhan8796/kubernetes that referenced this pull request Jun 26, 2026
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 kubernetes#48209

Associate PR against `k8s.io/utils` repo: kubernetes/utils#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.