Skip to content

🐛 Avoid marshalling error in debug log line #989

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 1 commit into from
Aug 4, 2020

Conversation

databus23
Copy link
Contributor

@databus23 databus23 commented Jun 10, 2020

Currently every webhook requests ended up logging this in debug:

2020-06-10T16:04:20.883+0200	DEBUG	controller-runtime.webhook.webhooks	wrote response	{"webhook": "/validate-some-resource", "UID": "e5d00608-7f47-4d00-bd91-b1a8955dc5a7", "allowed": true, "result": {}, "resultError": "got runtime.Object without object metadata: &Status{ListMeta:ListMeta{SelfLink:,ResourceVersion:,Continue:,RemainingItemCount:nil,},Status:,Message:,Reason:,Details:nil,Code:200,}"}

The problem is that a Status Object is a runtime.Object with no metadata which is not well received by the zap.KubeAwareEncoder.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 10, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @databus23. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 10, 2020
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 10, 2020
@databus23 databus23 changed the title Avoid marshalling error in debug log line 🐛 Avoid marshalling error in debug log line Jun 10, 2020
@databus23 databus23 changed the title 🐛 Avoid marshalling error in debug log line 🐛 Avoid marshalling error in debug log line Jun 10, 2020
@vincepri
Copy link
Member

vincepri commented Aug 3, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 3, 2020
@vincepri
Copy link
Member

vincepri commented Aug 3, 2020

/assign @alvaroaleman
/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2020
@@ -99,6 +99,6 @@ func (wh *Webhook) writeResponse(w io.Writer, response Response) {
wh.writeResponse(w, Errored(http.StatusInternalServerError, err))
} else {
res := responseAdmissionReview.Response
wh.log.V(1).Info("wrote response", "UID", res.UID, "allowed", res.Allowed, "result", res.Result)
wh.log.V(1).Info("wrote response", "UID", res.UID, "allowed", res.Allowed, "code", res.Result.Code, "reason", res.Result.Reason)
Copy link
Member

Choose a reason for hiding this comment

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

res.Result might be nil if the request gets approved, if we just unconditionally access it like this we might panic

Copy link
Member

Choose a reason for hiding this comment

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

/hold

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups. Good catch!

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2020
@databus23 databus23 force-pushed the patch-2 branch 3 times, most recently from 0bd08ae to 21139a3 Compare August 4, 2020 08:59
Currently every webhook requests ended up logging this in debug:
```
2020-06-10T16:04:20.883+0200	DEBUG	controller-runtime.webhook.webhooks	wrote response	{"webhook": "/validate-some-resource", "UID": "e5d00608-7f47-4d00-bd91-b1a8955dc5a7", "allowed": true, "result": {}, "resultError": "got runtime.Object without object metadata: &Status{ListMeta:ListMeta{SelfLink:,ResourceVersion:,Continue:,RemainingItemCount:nil,},Status:,Message:,Reason:,Details:nil,Code:200,}"}
```

The problem is that a `Status` Object is a runtime.Object but which has no metadata which is not well received the `KubeAwareEncoder`.

Signed-off-by: Fabian Ruff <[email protected]>
@databus23
Copy link
Contributor Author

/retest

@databus23
Copy link
Contributor Author

@vincepri I addressed the nil pointer access. Not sure about the failing tests now. I think its unrelated timeouts happening somewhere else.

@databus23
Copy link
Contributor Author

/test pull-controller-runtime-test-master

Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks!

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

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: databus23, vincepri

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vincepri
Copy link
Member

vincepri commented Aug 4, 2020

/hold cancel
/milestone v0.6.x

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 4, 2020
@k8s-ci-robot k8s-ci-robot added this to the v0.6.x milestone Aug 4, 2020
@vincepri
Copy link
Member

vincepri commented Aug 4, 2020

/retest

@k8s-ci-robot k8s-ci-robot merged commit 1abbd13 into kubernetes-sigs:master Aug 4, 2020
@vassilvk
Copy link

@databus23, did this fix make it into 0.6.2?
I upgraded from 0.5.0 to 0.6.2, but I'm still getting the got runtime.Object without object metadata error.

@vassilvk
Copy link

@databus23 - actually - never mind :)
I was looking at the wrong binary.
It works as expected with 0.6.2 - thank you!!!

@vincepri
Copy link
Member

Needs a new release, probably going to do one tomorrow if time permits

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants