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

YAMLDecoder Read function always returns n=0 bytes #56999

Closed
sel opened this issue Dec 10, 2017 · 4 comments · Fixed by #57000
Closed

YAMLDecoder Read function always returns n=0 bytes #56999

sel opened this issue Dec 10, 2017 · 4 comments · Fixed by #57000
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@sel
Copy link
Contributor

sel commented Dec 10, 2017

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

/kind bug

/kind feature

What happened:

In a go program, using the YAML utility package "k8s.io/apimachinery/pkg/util/yaml", the
YAMLDecoder Read function always returns n=0 bytes, indicating that nothing was read.

What you expected to happen:

The number of bytes read should be returned as specified in the Read contract

How to reproduce it (as minimally and precisely as possible):

func TestYAMLDecoder(t *testing.T) {
	d := `---
stuff: 1
	test-foo: 1
`
	s := NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader([]byte(d))))
	b := make([]byte, len(d))
	n, err := s.Read(b)
	if err != nil || n != len(d) {
		t.Fatalf("unexpected body: %d / %v", n, err)
	}
}

See sel@86d02ac#diff-3b3ea800b8ebe625d0defd76c2e6f827

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.4", GitCommit:"9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:"clean", BuildDate:"2017-11-20T05:28:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
  • Cloud provider or hardware configuration: minikube & AWS
  • OS (e.g. from /etc/os-release): macOS 10.13.1 (17B1003)
  • Kernel (e.g. uname -a): Darwin 17.2.0
  • Install tools:
  • Others: go version go1.9.2 darwin/amd64
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 10, 2017
@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 10, 2017
@sel
Copy link
Contributor Author

sel commented Dec 10, 2017

@kubernetes/sig-api-machinery-bugs

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Dec 10, 2017
@k8s-ci-robot
Copy link
Contributor

@sel: Reiterating the mentions to trigger a notification:
@kubernetes/sig-api-machinery-bugs

In response to this:

@kubernetes/sig-api-machinery-bugs

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Dec 10, 2017
@roycaihw
Copy link
Member

/cc @yliaog

@jennybuckley
Copy link

@jennybuckley

k8s-github-robot pushed a commit that referenced this issue Dec 18, 2017
Automatic merge from submit-queue (batch tested with PRs 57324, 56931, 57000, 57150, 56965). 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 YAMLDecoder Read behaviour

**What this PR does / why we need it**:

Makes YAMLDecoder adhere to the Read contract by returning the number of bytes
read.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #56999

**Special notes for your reviewer**:

**Release note**:

```release-note
YAMLDecoder Read now returns the number of bytes read
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants