-
Notifications
You must be signed in to change notification settings - Fork 165
ROX-14358: Ensure RHCOS logging is informative #5469
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
8a488f6
aa93135
eaa6881
907d609
ea2f8ca
4b7836a
e6e18d1
c332ff4
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 |
---|---|---|
|
@@ -63,36 +63,34 @@ func (p *pipelineImpl) Run(ctx context.Context, _ string, msg *central.MsgFromSe | |
if ninv == nil { | ||
return errors.Errorf("unexpected resource type %T for node inventory", event.GetResource()) | ||
} | ||
invStr := fmt.Sprintf("for node %s (id: %s)", ninv.GetNodeName(), ninv.GetNodeId()) | ||
log.Infof("received node inventory %s", invStr) | ||
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. I think this INFO is helpful. Removing it reduces the visibility of a critical piece of information. The rate of inventories doesn't justify removing it. What is the rationale? Is there another log or pointer that would give people the same information? 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. Yes, there is a replacement for it:
I moved this to debug, as otherwise the info would be printed twice. |
||
log.Debugf("node inventory %s contains %d packages to scan from %d content sets", invStr, | ||
nodeStr := fmt.Sprintf("(node name: %q, node id: %q)", ninv.GetNodeName(), ninv.GetNodeId()) | ||
log.Debugf("received inventory %s contains %d packages to scan from %d content sets", nodeStr, | ||
len(ninv.GetComponents().GetRhelComponents()), len(ninv.GetComponents().GetRhelContentSets())) | ||
if event.GetAction() != central.ResourceAction_UNSET_ACTION_RESOURCE { | ||
log.Errorf("node inventory %s with unsupported action: %s", invStr, event.GetAction()) | ||
log.Errorf("inventory %s has unsupported action: %q", nodeStr, event.GetAction()) | ||
return nil | ||
} | ||
ninv = ninv.Clone() | ||
|
||
// Read the node from the database, if not found we fail. | ||
node, found, err := p.nodeDatastore.GetNode(ctx, ninv.GetNodeId()) | ||
if err != nil { | ||
log.Errorf("fetching node (id: %q) from the database: %v", ninv.GetNodeId(), err) | ||
log.Errorf("fetching node %s from the database: %v", nodeStr, err) | ||
return errors.WithMessagef(err, "fetching node: %s", ninv.GetNodeId()) | ||
} | ||
if !found { | ||
log.Errorf("fetching node (id: %q) from the database: node does not exist", ninv.GetNodeId()) | ||
log.Errorf("fetching node %s from the database: node does not exist", nodeStr) | ||
return errors.WithMessagef(err, "node does not exist: %s", ninv.GetNodeId()) | ||
} | ||
log.Debugf("node %s found, enriching with node inventory", nodeDatastore.NodeString(node)) | ||
|
||
// Call Scanner to enrich the node inventory and attach the results to the node object. | ||
err = p.enricher.EnrichNodeWithInventory(node, ninv) | ||
if err != nil { | ||
log.Errorf("enriching node %s: %v", nodeDatastore.NodeString(node), err) | ||
return errors.WithMessagef(err, "enrinching node %s", nodeDatastore.NodeString(node)) | ||
} | ||
log.Debugf("node inventory for node %s has been scanned and contains %d results", | ||
nodeDatastore.NodeString(node), len(node.GetScan().GetComponents())) | ||
log.Infof("scanned inventory from node %s with %d components", nodeDatastore.NodeString(node), | ||
len(node.GetScan().GetComponents())) | ||
|
||
// Update the whole node in the database with the new and previous information. | ||
err = p.riskManager.CalculateRiskAndUpsertNode(node) | ||
|
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.
You might have nodes with the same name in an envrionment with multiple clusters. Considering OCP, I am unsure if this is something customers can do. I would have to check. But regardless, doing (a.) A standardized representation of a node object based on
nodeDatastore.NodeString(node)
, and doing (b.) Ensuring the cluster is associated with it will make these log lines survive when we start handling secured clusters that are not OCP. Also, in other places, I've seen nodes being referenced as "cluster/node", although it's not standardized everywhere. Considering the above, what improvements are we getting from removing the cluster name from the logs?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 find using the standard node string as a good idea! The problem is that it requires to have the
node
object, but in the discussed place in code (central/sensor/service/pipeline/nodeinventory/pipeline.go
) we do not have it yet. Only later, we query the DB and fetch the node object for the given node inventory.I will add the IDs to each node names in places where we could not get the cluster name. Would that be okay?
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, that was the original approach, if I remember correctly. Thanks for improving it.