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

Handle error when copying log from initializer in controller #456

Closed
pablochacin opened this issue Aug 29, 2024 · 1 comment · Fixed by #468
Closed

Handle error when copying log from initializer in controller #456

pablochacin opened this issue Aug 29, 2024 · 1 comment · Fixed by #468
Labels
bug Something isn't working
Milestone

Comments

@pablochacin
Copy link
Collaborator

Brief summary

When investigating an error running a test I fund this message in the controller's log:

2024-08-28T16:57:38Z    ERROR   controllers.TestRun     unable to marshal: ``   {"namespace": "default", "name": "mytest", "reconcileID": "0f346969-ff9a-4e00-bf96-22c3ff880675", "error": "unexpected end of JSON input"}
github.com/grafana/k6-operator/controllers.inspectTestRun
        /workspace/controllers/common.go:111

Looking at the code I found an unhandled error when reading logs from the pod (line 104) that can be hiding the root cause of this error:

102	buf := new(bytes.Buffer)
103	_, returnErr = io.Copy(buf, podLogs)
104	if err != nil {    <--- this should be returnErr
105		log.Error(err, "unable to copy logs from the pod")
106		return
107	}
108
109	if returnErr = json.Unmarshal(buf.Bytes(), &inspectOutput); returnErr != nil {
110		// this shouldn't normally happen but if it does, let's log output by default
111		log.Error(returnErr, fmt.Sprintf("unable to marshal: `%s`", buf.String()))
112	}

k6-operator version or image

v0.0.16

Helm chart version (if applicable)

No response

TestRun / PrivateLoadZone YAML

apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
  name: mytest
spec:
  parallelism: 1
  script:
    configMap:
      name: k6test
      file: sqlite.js
  runner:
    image: ghcr.io/grafana/k6exec:latest

Other environment details (if applicable)

Trying to run a test with a custom runner image

Steps to reproduce the problem

N/A

Expected behaviour

N/A

Actual behaviour

N/A

@pablochacin pablochacin added the bug Something isn't working label Aug 29, 2024
@yorugac yorugac changed the title Unhandle error when copying log from pod in controller Handle error when copying log from initializer in controller Sep 3, 2024
@yorugac
Copy link
Collaborator

yorugac commented Sep 5, 2024

Thanks for reporting this, @pablochacin! Yes, this looks like a typo 🙁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants