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

Check exit code of hostname -f for failures #219

Merged
merged 4 commits into from
Jan 30, 2020
Merged

Check exit code of hostname -f for failures #219

merged 4 commits into from
Jan 30, 2020

Conversation

zippolyte
Copy link
Contributor

What does this PR do?

fixes #57

Description of the Change

%x["hostname -f"] call doesn't necessarily raise a SystemCallError (on windows 10 notably) on failure, so additionally check for exit status code.

Verification Process

manual testing on windows

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@@ -200,9 +200,12 @@ def Dogapi.find_datadog_host
@@hostname = nil

def Dogapi.find_localhost
@@hostname ||= %x[hostname -f].strip
unless @@hostname
@@hostname, status = Open3.capture2("hostname", "-f", :err=>File::NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to strip whitespaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh good catch

jirikuncar
jirikuncar previously approved these changes Jan 30, 2020
Copy link
Contributor

@jirikuncar jirikuncar left a comment

Choose a reason for hiding this comment

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

💚

@zippolyte zippolyte merged commit 309664f into master Jan 30, 2020
@zippolyte zippolyte deleted the hippo/hw branch January 30, 2020 10:07
@zippolyte zippolyte added the changelog/Fixed Fixed features results into a bug fix version bump label Feb 4, 2020
KSerrania added a commit to DataDog/chef-handler-datadog that referenced this pull request Nov 5, 2020
Updates the dogapi gem dependency to its latest version, in particular to get DataDog/dogapi-rb#219.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Fixed Fixed features results into a bug fix version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hostname -s option produces error on some Windows versions
2 participants