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

feat(host_analyzer): add host sysctl analyzer #1681

Merged
merged 6 commits into from
Nov 8, 2024

Conversation

JGAntunes
Copy link
Member

@JGAntunes JGAntunes commented Nov 8, 2024

Description, Motivation and Context

Fixes - #1675

Running it locally:

sudo bin/preflight -v 5 examples/preflight/host/sysctl.yaml
Sysctl Preflight Checks


┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│⚠️  Sysctl                                                                                                                                                  │  Sysctl
│                                                                                                                                                            │
│                                                                                                                                                            │
│                                                                                                                                                            │ Running sysctl on a Darwin host
│                                                                                                                                                            │

image

Checklist

Does this PR introduce a breaking change?

  • Yes
  • No

@JGAntunes JGAntunes added the type::feature New feature or request label Nov 8, 2024
@JGAntunes JGAntunes self-assigned this Nov 8, 2024
@JGAntunes JGAntunes requested a review from a team as a code owner November 8, 2024 12:47
@@ -38,7 +38,7 @@ func (a *AnalyzeHostTime) Analyze(
getCollectedFileContents,
collect.HostTimePath,
collect.NodeInfoBaseDir,
collect.HostMemoryFileName,
collect.HostTimeFileName,
Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed the time collector was using the memory collector file name, not really part of the bulk of this changes but thought it would be a useful fix.

Comment on lines 325 to 331
case c.Collect.Sysctl != nil:
hostCollect.HostSysctl = &troubleshootv1beta2.HostSysctl{
HostCollectorMeta: troubleshootv1beta2.HostCollectorMeta{
CollectorName: c.Collect.Sysctl.CollectorName,
Exclude: c.Collect.Sysctl.Exclude,
},
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure if it makes sense to have this collector support remote collection too given we also have - https://troubleshoot.sh/docs/collect/sysctl/#heading - but I decided to follow the pattern we're using for all of our host collectors.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, everything you see in the files named specifically around "remote_collector" is actually code we're planning to deprecate. So we don't need to add this here nor do we need to update the GVK for Remote Collectors

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

Done via - 258d883

@JGAntunes JGAntunes requested a review from banjoh November 8, 2024 12:52
Comment on lines 158 to 161
type RemoteSysctl struct {
RemoteCollectorMeta `json:",inline" yaml:",inline"`
}

Copy link
Member

Choose a reason for hiding this comment

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

We can get rid of the changes in this file. This code path is going to be deprecated hopefully soon

Copy link
Member Author

Choose a reason for hiding this comment

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

@diamonwiggins should I remove it right now before merge? Or do you mean that soon we'll be able to remove it?

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

Done via - 258d883

diamonwiggins
diamonwiggins previously approved these changes Nov 8, 2024
Copy link
Member

@diamonwiggins diamonwiggins left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@banjoh banjoh left a comment

Choose a reason for hiding this comment

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

Looks good. I left some comments

}

param := matches[1]
operator := matches[2]
Copy link
Member

@banjoh banjoh Nov 8, 2024

Choose a reason for hiding this comment

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

You can use ParseComparisonOperator to parse the operator

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah thank you! This is pretty useful. I'll use that one too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done via - 258d883

Comment on lines 325 to 331
case c.Collect.Sysctl != nil:
hostCollect.HostSysctl = &troubleshootv1beta2.HostSysctl{
HostCollectorMeta: troubleshootv1beta2.HostCollectorMeta{
CollectorName: c.Collect.Sysctl.CollectorName,
Exclude: c.Collect.Sysctl.Exclude,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

+1

Comment on lines 158 to 161
type RemoteSysctl struct {
RemoteCollectorMeta `json:",inline" yaml:",inline"`
}

Copy link
Member

Choose a reason for hiding this comment

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

+1

@JGAntunes JGAntunes merged commit 197f6de into main Nov 8, 2024
24 checks passed
@JGAntunes JGAntunes deleted the feat/host_sysctl_analyzer branch November 8, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants