Skip to content

tests: Fixes DNS tests false positives#70242

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
claudiubelu:fixes-dns-false-positives
Oct 30, 2018
Merged

tests: Fixes DNS tests false positives#70242
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
claudiubelu:fixes-dns-false-positives

Conversation

@claudiubelu
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

/sig testing

What this PR does / why we need it:

If dig fails to reach the DNS, it will output errors to stdout, which
can cause the test -n to falsely pass:

ubuntu@ubuntu:~$ dig +notcp +noall +answer +search kubernetes.default A
;; connection timed out; no servers could be reached
command terminated with exit code 9

ubuntu@ubuntu:~$ test -n "$(dig +notcp +noall +answer +search kubernetes.default A)" && echo OK
OK

This patch solves this issue by making sure the dig command actually succeeds
before checking its output.

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 #63366

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

If dig fails to reach the DNS, it will output errors to stdout, which
can cause the test -n to falsely pass:

ubuntu@ubuntu:~$ dig +notcp +noall +answer +search kubernetes.default A
;; connection timed out; no servers could be reached
command terminated with exit code 9

ubuntu@ubuntu:~$ test -n "$(dig +notcp +noall +answer +search kubernetes.default A)" && echo OK
OK

This patch solves this issue by making sure the dig command actually succeeds
before checking its output.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. sig/testing Categorizes an issue or PR as relevant to SIG Testing. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 25, 2018
@claudiubelu
Copy link
Copy Markdown
Contributor Author

/assign @dnardo

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.

I haven't investigated why the $s are doubled elsewhere, but do you need to double them in "$check" as well?

(Also, an alternative approach would be to just append 2>/dev/null to the dig command, to discard stderr so you're only checking stdout.)

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.

The explanation for $$ is just a few lines above this change. Basically, it says that $(...) is expanded by Kubernetes, which is why $$(...) is used instead. It doesn't say anything about $var_name though.

But for the 2> /dev/null thing, it won't work, because dig explicitly outputs the error to stdout instead of stderr. Otherwise, this shouldn't have been an issue in the 1st place.

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.

For example:

ubuntu@ubuntu:~$ dig +notcp +noall +answer +search kubernetes.default.svc.cluster.local A
;; connection timed out; no servers could be reached
ubuntu@ubuntu:~$ dig +notcp +noall +answer +search kubernetes.default.svc.cluster.local A 2> /dev/null
;; connection timed out; no servers could be reached

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.

And as far as $check or $$check goes, it seems that they both behave the same.

@claudiubelu claudiubelu force-pushed the fixes-dns-false-positives branch from 15a8cdc to fb8d2f7 Compare October 25, 2018 17:08
@danwinship
Copy link
Copy Markdown
Contributor

/lgtm
/ok-to-test

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 25, 2018
@claudiubelu
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-integration

@spiffxp
Copy link
Copy Markdown
Contributor

spiffxp commented Oct 30, 2018

/area conformance

@k8s-ci-robot k8s-ci-robot added the area/conformance Issues or PRs related to kubernetes conformance tests label Oct 30, 2018
@spiffxp
Copy link
Copy Markdown
Contributor

spiffxp commented Oct 30, 2018

/approve
FYI @kubernetes/cncf-conformance-wg

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bclau, spiffxp

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2018
@k8s-ci-robot k8s-ci-robot merged commit f9c744a into kubernetes:master Oct 30, 2018
@claudiubelu claudiubelu deleted the fixes-dns-false-positives branch April 19, 2019 13:38
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/conformance Issues or PRs related to kubernetes conformance tests cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

DNS tests may pass if DNS not configured or unreachable

5 participants