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

Output HostStatsCollector's Collect errors #1535

Merged
merged 2 commits into from
Aug 11, 2016
Merged

Output HostStatsCollector's Collect errors #1535

merged 2 commits into from
Aug 11, 2016

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Aug 7, 2016

No description provided.

@@ -80,6 +83,8 @@ func (h *HostStatsCollector) Collect() (*HostStats, error) {
Free: memStats.Free,
}
hs.Memory = ms
} else {
Copy link
Contributor

@diptanu diptanu Aug 8, 2016

Choose a reason for hiding this comment

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

Let's remove the if/else statements.

memStats, err := mem.VirtualMemory()
....
if err != nil {
   return nil, err
}

Copy link
Contributor Author

@nak3 nak3 Aug 9, 2016

Choose a reason for hiding this comment

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

@diptanu I agree that removing if/else statements. But return nil, err is OK?

if err != nil {
   return nil, err
}

I thought it should collect errors as below like you commented.

mErr.Errors = append(mErr.Errors, fmt.Errorf("error to collect cpu stats", err))

Copy link
Contributor

Choose a reason for hiding this comment

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

@nak3 Yeah this is ok, since even if we collect more stats but return an error we won't update the stats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diptanu I see. Thank you.

@diptanu
Copy link
Contributor

diptanu commented Aug 8, 2016

I initially didn't want to report any errors since I wanted to collect as much stats I could in the event stats collection of a particular sub-system was failing.

@@ -139,7 +139,7 @@ func TestConfig_Merge(t *testing.T) {
"foo": "bar",
"baz": "zip",
},
ChrootEnv: map[string]string{},
ChrootEnv: map[string]string{},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is a fix for gofmt error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@nak3
Copy link
Contributor Author

nak3 commented Aug 11, 2016

@diptanu Thank you. I updated.

if err != nil {
return nil, err
}
ms := &MemoryStats{
Copy link
Contributor

Choose a reason for hiding this comment

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

hs.Memory := &MemoryStats {

@nak3
Copy link
Contributor Author

nak3 commented Aug 11, 2016

@diptanu Thank you. I updated.

@diptanu diptanu merged commit 97a7173 into hashicorp:master Aug 11, 2016
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants