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

tests/e2e.sh: Check for errors in the logs #819

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

lilic
Copy link
Member

@lilic lilic commented Jul 11, 2019

What this PR does / why we need it:
kube-state-metrics does not terminate the pod on errors, so to actually
detect the errors in CI, we are adding this check by grepping for errors
in the kube-state-metrics logs.

This makes the assumption that any errors that are present in logs start
wtih the string 'E' (e.g.: 'E0711') as this is how klog starts
all error log lines.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
As discussed in #815 (comment)

Tested this with errors in logs and it looks like this on FAIL:

check for errors in logs
E0711 15:51:09.896317       1 reflector.go:342] k8s.io/kube-state-metrics/internal/store/builder.go:295: expected type *v1beta1.ReplicaSet, but watch event object had type *v1.ReplicaSet
=======================================
found errors in kube-state-metrics logs
=======================================
I0711 15:51:02.037704       1 main.go:87] Using default collectors
I0711 15:51:02.037789       1 main.go:99] Using all namespace
I0711 15:51:02.037809       1 main.go:140] metric white-blacklisting: blacklisting the following items: 
W0711 15:51:02.039405       1 client_config.go:541] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
I0711 15:51:02.041468       1 main.go:185] Testing communication with server
I0711 15:51:02.054346       1 main.go:190] Running with Kubernetes cluster version: v1.14. git version: v1.14.3. git tree state: clean. commit: 5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0. platform: linux/amd64
I0711 15:51:02.054371       1 main.go:192] Communication with server successful
I0711 15:51:02.055704       1 builder.go:126] Active collectors: certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,limitranges,namespaces,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses
I0711 15:51:02.055727       1 main.go:226] Starting metrics server: 0.0.0.0:8080
I0711 15:51:02.058555       1 main.go:201] Starting kube-state-metrics self metrics server: 0.0.0.0:8081
E0711 15:51:09.896317       1 reflector.go:342] k8s.io/kube-state-metrics/internal/store/builder.go:295: expected type *v1beta1.ReplicaSet, but watch event object had type *v1.ReplicaSet

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 11, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 11, 2019
@lilic
Copy link
Member Author

lilic commented Jul 11, 2019

cc @tariq1890 @brancz

@lilic
Copy link
Member Author

lilic commented Jul 11, 2019

This is failing because the previous fix was not merged into master just into the release branch. Should be passing after #820 is merged. But it shows the e2e test in place works! 🎉 :)

tests/e2e.sh Outdated
echo "found errors in kube-state-metrics logs"
echo "======================================="
echo ""
echo "$output_logs"
Copy link
Contributor

Choose a reason for hiding this comment

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

So are we printing out the entire log here? Why not pipe the matched lines and echo that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@tariq1890 This is because before we were printing out the entire log as well, that was on an error. I think it's relevant if there are errors in the logs to print out the entire log so we can debug easier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Thanks!

tests/e2e.sh Outdated
klog_err=E$(date +%m%d)
echo "check for errors in logs"
output_logs=$(kubectl --namespace=kube-system logs deployment/kube-state-metrics kube-state-metrics)
if echo "$output_logs" | grep "^$klog_err"; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's use the brace var expansion for all the variable references you have added in this PR.

Copy link
Contributor

@tariq1890 tariq1890 left a comment

Choose a reason for hiding this comment

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

PR looks good. Should be good to go after addressing the nits and rebase. Thanks @lilic !

tests/e2e.sh Outdated
if echo "$output_logs" | grep "^$klog_err"; then
echo ""
echo "======================================="
echo "found errors in kube-state-metrics logs"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo "found errors in kube-state-metrics logs"
echo "Found errors in the kube-state-metrics logs"

kube-state-metrics does not terminate the pod on errors, so to actually
detect the errors in CI, we are adding this check by grepping for errors
in the kube-state-metrics logs.

This makes the assumption that any errors that are present in logs start
wtih the string 'E<MONTHDAY>' (e.g.: 'E0711') as this is how klog starts
all error log lines.
@lilic
Copy link
Member Author

lilic commented Jul 12, 2019

@tariq1890 should be ready for a re-review, thanks!

@brancz
Copy link
Member

brancz commented Jul 12, 2019

lgtm but giving @tariq1890 another chance to review :)

@tariq1890
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 12, 2019
Copy link
Contributor

@tariq1890 tariq1890 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: LiliC, tariq1890

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

@k8s-ci-robot k8s-ci-robot merged commit 7e891f0 into kubernetes:master Jul 12, 2019
@lilic lilic deleted the e2e-error-log branch July 12, 2019 17:21
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants