Skip to content

Improve state reporting in kube checks#2082

Merged
knative-prow-robot merged 4 commits into
knative:mainfrom
skonto:imp-test-state-report
Apr 16, 2021
Merged

Improve state reporting in kube checks#2082
knative-prow-robot merged 4 commits into
knative:mainfrom
skonto:imp-test-state-report

Conversation

@skonto
Copy link
Copy Markdown
Contributor

@skonto skonto commented Apr 2, 2021

Changes

  • Report state in kube checks

Fixes #996

@google-cla google-cla Bot added the cla: yes Indicates the PR's author has signed the CLA. label Apr 2, 2021
@knative-prow-robot knative-prow-robot added area/test-and-release size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 2, 2021
@skonto skonto changed the title Improve state reporting in kube check Improve state reporting in kube checks Apr 2, 2021
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2021

Codecov Report

Merging #2082 (1ead025) into main (952fdd9) will decrease coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2082      +/-   ##
==========================================
- Coverage   67.36%   67.31%   -0.06%     
==========================================
  Files         215      215              
  Lines        9111     9092      -19     
==========================================
- Hits         6138     6120      -18     
+ Misses       2698     2697       -1     
  Partials      275      275              
Impacted Files Coverage Δ
injection/config.go 0.00% <0.00%> (ø)
reconciler/filter.go 100.00% <0.00%> (ø)
network/domain.go 50.00% <0.00%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 952fdd9...1ead025. Read the comment docs.

Comment thread test/kube_checks.go Outdated
})

if waitErr != nil {
return fmt.Errorf("deployment %q is not in desired state, got: %+v: %w", name, lastState, waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we print the big structs via spew.Sprint. It resolves pointers and stuff. We use that in Serving wherever actual debugging output of full K8s resources is necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes ok.

Comment thread test/kube_checks.go Outdated

if waitErr != nil {
return fmt.Errorf("deployment %q is not in desired state, got: %+v: %w", name, lastState, waitErr)
return errors.New(spew.Sprintf("deployment %q is not in desired state, got: %+v: %w", name, lastState, waitErr))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why move away from Errorf here? I'd have kept that and would propose:

return fmt.Errorf("deployment %q is not in desired state, error: %w, state:\n%s", name, waitErr spew.Sprint(lastState))

Copy link
Copy Markdown
Contributor Author

@skonto skonto Apr 8, 2021

Choose a reason for hiding this comment

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

Why not? It is another way to do it. It covers all other arguments too without thinking too much about them (their size etc). Anyway I can change.

Copy link
Copy Markdown
Contributor Author

@skonto skonto Apr 8, 2021

Choose a reason for hiding this comment

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

I think I could have used spew.Errorf() to have only one call if I want to make spew parse all arguments btw.

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 8, 2021

TestMetricsExport again.

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 8, 2021

/retest

1 similar comment
@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 13, 2021

/retest

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 13, 2021

@markusthoemmes gentle ping. The test keeps failing but it is unrelated I have a PR to fix that infamous test here #2088 .

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 15, 2021

@markusthoemmes gentle ping for a merge.

Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

LGTM apart from the nits. The only important one I believe is the logs output.

Comment thread test/kube_checks.go
return strings.Contains(string(logs), content), nil
})
if waitErr != nil {
return fmt.Errorf("logs do not contain the desired content %q, got %q: %w", content, logs, waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("logs do not contain the desired content %q, got %q: %w", content, logs, waitErr)
return fmt.Errorf("logs do not contain the desired content %q, got %q: %w", content, string(logs), waitErr)

I believe this gets us a messy byte output otherwise.

Copy link
Copy Markdown
Contributor Author

@skonto skonto Apr 15, 2021

Choose a reason for hiding this comment

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

I checked that before, so the rules say for byte slices with %q: %q a double-quoted string safely escaped with Go syntax. Even %s works (but no quotes). Check here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh wow interesting!

Comment thread test/kube_checks.go Outdated
})

if waitErr != nil {
return fmt.Errorf("pod %q is not in desired state, got: %+v: %w", name, spew.Sprint(lastState), waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("pod %q is not in desired state, got: %+v: %w", name, spew.Sprint(lastState), waitErr)
return fmt.Errorf("pod %q is not in desired state, got: %s: %w", name, spew.Sprint(lastState), waitErr)

just a nit, but for completeness sake.

Comment thread test/kube_checks.go Outdated
})

if waitErr != nil {
return fmt.Errorf("pod list is not in desired state, got: %+v: %w", spew.Sprint(lastState), waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("pod list is not in desired state, got: %+v: %w", spew.Sprint(lastState), waitErr)
return fmt.Errorf("pod list is not in desired state, got: %s: %w", spew.Sprint(lastState), waitErr)

Comment thread test/kube_checks.go Outdated
})

if waitErr != nil {
return fmt.Errorf("deployment %q is not in desired state, got: %+v: %w", name, spew.Sprint(lastState), waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("deployment %q is not in desired state, got: %+v: %w", name, spew.Sprint(lastState), waitErr)
return fmt.Errorf("deployment %q is not in desired state, got: %s: %w", name, spew.Sprint(lastState), waitErr)

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 15, 2021
@markusthoemmes
Copy link
Copy Markdown
Contributor

/assign

Please assign me if you want a review, i'll see it pop up in my Github state.

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 15, 2021

/assign @markusthoemmes

@markusthoemmes
Copy link
Copy Markdown
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2021
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2021
@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 16, 2021

@markusthoemmes gentle ping.

Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

The PR won't merge without the unit test passing though

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2021
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markusthoemmes

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

The pull request process is described here

Details 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

@skonto
Copy link
Copy Markdown
Contributor Author

skonto commented Apr 16, 2021

/retest

@knative-prow-robot knative-prow-robot merged commit b80a192 into knative:main Apr 16, 2021
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. area/test-and-release cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFE: func WaitForXXXX should print last state of the resource when failed

3 participants