-
Notifications
You must be signed in to change notification settings - Fork 174
ROX-13722: [Prefactor] Do not use scanner protos in node.proto #4392
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
Changes from all commits
967d082
6adf1a9
05a3dd9
1544adb
b539461
36de34d
fdbd8cd
2bed400
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,13 +44,13 @@ func (n *NodeInventoryCollector) Scan(nodeName string) (*storage.NodeInventory, | |
| NodeName: nodeName, | ||
| ScanTime: timestamp.TimestampNow(), | ||
| Components: protoComponents, | ||
| Notes: []scannerV1.Note{scannerV1.Note_LANGUAGE_CVES_UNAVAILABLE}, | ||
| Notes: []storage.NodeInventory_Note{storage.NodeInventory_LANGUAGE_CVES_UNAVAILABLE}, | ||
| } | ||
|
|
||
| return m, nil | ||
| } | ||
|
|
||
| func protoComponentsFromScanComponents(c *nodes.Components) *scannerV1.Components { | ||
| func protoComponentsFromScanComponents(c *nodes.Components) *storage.NodeInventory_Components { | ||
| if c == nil { | ||
| return nil | ||
| } | ||
|
|
@@ -66,33 +66,36 @@ func protoComponentsFromScanComponents(c *nodes.Components) *scannerV1.Component | |
| // For now, we only care about RHEL components, but this must be extended once we support non-RHCOS | ||
| rhelComponents := convertAndDedupRHELComponents(c.CertifiedRHELComponents) | ||
|
|
||
| protoComponents := &scannerV1.Components{ | ||
| Namespace: namespace, | ||
| OsComponents: nil, | ||
| RhelComponents: rhelComponents, | ||
| LanguageComponents: nil, | ||
| protoComponents := &storage.NodeInventory_Components{ | ||
| Namespace: namespace, | ||
| RhelComponents: rhelComponents, | ||
| } | ||
| return protoComponents | ||
| } | ||
|
|
||
| func convertAndDedupRHELComponents(rc *database.RHELv2Components) []*scannerV1.RHELComponent { | ||
| func convertAndDedupRHELComponents(rc *database.RHELv2Components) []*storage.NodeInventory_Components_RHELComponent { | ||
| if rc == nil || rc.Packages == nil { | ||
| log.Warn("No RHEL packages found in scan result") | ||
| return nil | ||
| } | ||
|
|
||
| convertedComponents := make(map[string]*scannerV1.RHELComponent, 0) | ||
| convertedComponents := make(map[string]*storage.NodeInventory_Components_RHELComponent, 0) | ||
| for i, rhelc := range rc.Packages { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worth adding a guard here for the case where
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in fdbd8cd |
||
| comp := &scannerV1.RHELComponent{ | ||
| if rhelc == nil { | ||
| continue | ||
| } | ||
| comp := &storage.NodeInventory_Components_RHELComponent{ | ||
| // The loop index is used as ID, as this field only needs to be unique for each NodeInventory result slice | ||
| Id: int64(i), | ||
| Name: rhelc.Name, | ||
| Namespace: rc.Dist, | ||
| Version: rhelc.Version, | ||
| Arch: rhelc.Arch, | ||
| Module: rhelc.Module, | ||
| Cpes: rc.CPEs, | ||
| Executables: rhelc.Executables, | ||
| Executables: nil, | ||
| } | ||
| if rhelc.Executables != nil { | ||
| comp.Executables = convertExecutables(rhelc.Executables) | ||
| } | ||
| compKey := makeComponentKey(comp) | ||
| if compKey != "" { | ||
|
|
@@ -108,6 +111,26 @@ func convertAndDedupRHELComponents(rc *database.RHELv2Components) []*scannerV1.R | |
| return maps.Values(convertedComponents) | ||
| } | ||
|
|
||
| func makeComponentKey(component *scannerV1.RHELComponent) string { | ||
| func convertExecutables(exe []*scannerV1.Executable) []*storage.NodeInventory_Components_RHELComponent_Executable { | ||
| arr := make([]*storage.NodeInventory_Components_RHELComponent_Executable, len(exe)) | ||
| for i, executable := range exe { | ||
| arr[i] = &storage.NodeInventory_Components_RHELComponent_Executable{ | ||
| Path: executable.GetPath(), | ||
| RequiredFeatures: nil, | ||
| } | ||
| if executable.GetRequiredFeatures() != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for switchting to getters here, as discussed in the sync review! |
||
| arr[i].RequiredFeatures = make([]*storage.NodeInventory_Components_RHELComponent_Executable_FeatureNameVersion, len(executable.GetRequiredFeatures())) | ||
| for i2, fnv := range executable.GetRequiredFeatures() { | ||
| arr[i].RequiredFeatures[i2] = &storage.NodeInventory_Components_RHELComponent_Executable_FeatureNameVersion{ | ||
| Name: fnv.GetName(), | ||
| Version: fnv.GetVersion(), | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return arr | ||
| } | ||
|
|
||
| func makeComponentKey(component *storage.NodeInventory_Components_RHELComponent) string { | ||
| return component.Name + ":" + component.Version + ":" + component.Arch + ":" + component.Module | ||
| } | ||
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 see you already incorporated the feedback regarding loglevels. Great job!
That said, we're keeping the pipeline only until #3757 is merged, as
NodeInventoryis still an independent message here, and we depend on this pipeline to print the inventory, correct?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.
Yes, no changes to the pipeline here as it affects the decision that we need to do in #3757.
The nodescanv2 pipeline is a dud and does nothing except of printing the debug log message. Moreover, it is guarded by the feature-flag - see here