Skip to content

ROX-13722: [Prefactor] Do not use scanner protos in node.proto#4392

Merged
vikin91 merged 8 commits intomasterfrom
piotr/ROX-13722-prefactor
Jan 17, 2023
Merged

ROX-13722: [Prefactor] Do not use scanner protos in node.proto#4392
vikin91 merged 8 commits intomasterfrom
piotr/ROX-13722-prefactor

Conversation

@vikin91
Copy link
Contributor

@vikin91 vikin91 commented Jan 13, 2023

Description

This PR is a prefactor for #3757. It contains all changes that are safe
to land as they do not affect other parts of the system than RHCOS node
scanning feature.

The changes here are:

  • No longer use scanner protos in the node.proto
  • Add rhel_content_sets field in storage.NodeInventory_Components - see Scanner #1053
  • Use more realistic fake data in the fake node inventory

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added

Do not apply

  • Evaluated and added CHANGELOG entry if required
  • Determined and documented upgrade steps
  • Documented user facing changes (create PR based on openshift/openshift-docs and merge into rhacs-docs)

If any of these don't apply, please comment below.

Testing Performed

  • CI
  • Deployed a test cluster and investigated logs for errors

@vikin91
Copy link
Contributor Author

vikin91 commented Jan 13, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@vikin91 vikin91 changed the title Do not use scanner protos in node.proto ROX-13722: [Prefactor] Do not use scanner protos in node.proto Jan 13, 2023
@ghost
Copy link

ghost commented Jan 13, 2023

Images are ready for the commit at 2bed400.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.73.x-408-g2bed40071e.

Copy link
Contributor

@Maddosaurus Maddosaurus left a comment

Choose a reason for hiding this comment

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

I spotted some well placed small additions, addressing feedback we discussed in the initial review of #3757.
Well done, thanks for the updates!


// TODO(ROX-12240, ROX-13053): Do something meaningful with the nodeInventory
log.Infof("Central received NodeInventory: %+v", nodeInventory)
log.Debugf("Central received NodeInventory: %+v", nodeInventory)
Copy link
Contributor

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 NodeInventory is still an independent message here, and we depend on this pipeline to print the inventory, correct?

Copy link
Contributor Author

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

Path: executable.Path,
RequiredFeatures: nil,
}
if executable.GetRequiredFeatures() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for switchting to getters here, as discussed in the sync review!

string version = 4;
string arch = 5;
string module = 6;
repeated string cpes = 7;
Copy link
Contributor

Choose a reason for hiding this comment

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

With rhel_content_sets we don't need cpes anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it removed in 36de34d

Copy link
Contributor

@rhybrillou rhybrillou left a comment

Choose a reason for hiding this comment

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

Good work.
Some additional bulletproofing can be added in some places.


convertedComponents := make(map[string]*scannerV1.RHELComponent, 0)
convertedComponents := make(map[string]*storage.NodeInventory_Components_RHELComponent, 0)
for i, rhelc := range rc.Packages {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth adding a guard here for the case where rhelc is a nil pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in fdbd8cd

arr := make([]*storage.NodeInventory_Components_RHELComponent_Executable, len(exe))
for i, executable := range exe {
arr[i] = &storage.NodeInventory_Components_RHELComponent_Executable{
Path: executable.Path,
Copy link
Contributor

Choose a reason for hiding this comment

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

executable.GetPath()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, added in fdbd8cd

if executable.GetRequiredFeatures() != nil {
arr[i].RequiredFeatures = make([]*storage.NodeInventory_Components_RHELComponent_Executable_FeatureNameVersion, len(executable.GetRequiredFeatures()))
}
for i2, fnv := range executable.GetRequiredFeatures() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: would it make sense to nest this for loop in the previous block after the array allocation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dded in fdbd8cd

// Components represents a subset of the scannerV1.Components proto message containing only fields required for RHCOS node scanning
// We are not using scannerV1.Components here for the following reasons:
// - to avoid conflicts between v1 and scannerV1 APIs when generating the code in central/graphql/resolvers/generated.go
// - to not expose scanner v1 API over stackrox graphql API
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a note to keep scannerV1.Components and storage.NodeInventory_Components in sync ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added that in 2bed400. Note that the function that does the reverse conversion in Central will be first added in a future PR, so I left the description generic here.

@vikin91 vikin91 requested a review from jvdm January 16, 2023 16:59
Copy link
Contributor

@jvdm jvdm left a comment

Choose a reason for hiding this comment

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

LGTM.

@vikin91
Copy link
Contributor Author

vikin91 commented Jan 17, 2023

Thank you for all the reviews. I will merge this as it is as this state is a good starting point for further changes.

After meeting with Mandar yesterday, we might need to abandon #3757, readd node_id to NodeInventory and use a separate message (not Node) to transfer inventory between Sensor and Central.
I will make necessary experiments and explain why in the next days. Once we agree on that, I will readd the node_id in a followup to this PR.

@vikin91 vikin91 merged commit 39eab76 into master Jan 17, 2023
@vikin91 vikin91 deleted the piotr/ROX-13722-prefactor branch January 17, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants