-
Notifications
You must be signed in to change notification settings - Fork 94
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
Refactor Multi Node Analyzers #1646
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes looks good, I just have few comments and questions.
Understand that all other analyzers will have to use function retrieveCollectedContents
to retrieve the files before analyzing.
We will have to ensure that other host collectors follow directory convention of base dir system/<nodeName>/<file.json>
E.g. diskUsage
doesn't follow this at the moment.
host-collectors
├── diskUsage
│ └── gerard-kurl-0
│ └── diskUsage.json
└── system
├── gerard-kurl-0
│ ├── block_devices.json
│ ├── cpu.json
│ ├── hostos_info.json
│ └── memory.json
└── node_list.json
Also, does this PR mean other analyzers will just have to implement method CheckCondition
for the analyzing part?
Yup, every analyzer will just need to move their |
d217ad1
to
c05d677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the direction this PR has taken. This will DRY quite many of the host analysers. I've left some minor code comment changes
A change we can consider doing is moving node-list.json
a directory higher to remove the duplicate file that gets created. It's not a major issue since it will contain the same contents.
pkg/analyze/host_analyzer.go
Outdated
if err != nil { | ||
return nil, errors.Wrap(err, "failed to evaluate outcomes") | ||
} | ||
results = append(results, analyzeResult...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
analyzeResult
can be nil
. Check if nil
pkg/analyze/collected_contents.go
Outdated
type CollectedContent struct { | ||
NodeName string | ||
Data CollectorData | ||
} | ||
|
||
type CollectorData interface{} | ||
|
||
type NodeNames struct { | ||
Nodes []string `json:"nodes"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these structs private. They are not used outside of analyze
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will now have an analysis result for each node. I think we need to indicate which node a results is for. A prefix perhaps?
Ignore this comment. I just saw code doing this |
0d34ff9
to
72d375c
Compare
Hi @banjoh, could you help me review the updates? 🙇 |
Signed-off-by: Evans Mungai <evans@replicated.com>
The function to build collectors and filter excluded ones was making wrapping tracing spans a problem. We need one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description, Motivation and Context
Refactoring analyzers to be easier to write. All analyzers implement a function to check a condition and then return true/false. All analyzers also evaluate outcomes in a similar way.
The recently added code to check if there are contents from remote collection present and then proceed to use them and if not fallback to local contents is also code that can be shared amongst all analyzers.
The goal is that these changes makes it easier to update all remaining analyzers to be able to process remote collected contents, and also just easier to maintain and update host analyzers going forward.
TODO:
Checklist
Does this PR introduce a breaking change?