Skip to content
Merged
14 changes: 7 additions & 7 deletions central/sensor/service/pipeline/nodescansv2/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ func (p *pipelineImpl) Reconcile(ctx context.Context, clusterID string, storeMap
}

func (p *pipelineImpl) Match(msg *central.MsgFromSensor) bool {
return msg.GetEvent().GetNodeScanV2() != nil
return msg.GetEvent().GetNodeInventory() != nil
}

// Run runs the pipeline template on the input and returns the output.
func (p *pipelineImpl) Run(ctx context.Context, clusterID string, msg *central.MsgFromSensor, _ common.MessageInjector) error {
defer countMetrics.IncrementResourceProcessedCounter(pipeline.ActionToOperation(msg.GetEvent().GetAction()), metrics.NodeScanV2)
defer countMetrics.IncrementResourceProcessedCounter(pipeline.ActionToOperation(msg.GetEvent().GetAction()), metrics.NodeInventory)

event := msg.GetEvent()
nodeScan := event.GetNodeScanV2()
if nodeScan == nil {
return errors.Errorf("unexpected resource type %T for node scan v2", event.GetResource())
nodeInventory := event.GetNodeInventory()
if nodeInventory == nil {
return errors.Errorf("unexpected resource type %T for node inventory", event.GetResource())
}

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

return nil
}
Expand Down
8 changes: 4 additions & 4 deletions compliance/collection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func scanNode(nodeName string, scanner nodescanv2.NodeScanner) (*sensor.MsgFromC
}
return &sensor.MsgFromCompliance{
Node: nodeName,
Msg: &sensor.MsgFromCompliance_NodeScanV2{NodeScanV2: result},
Msg: &sensor.MsgFromCompliance_NodeInventory{NodeInventory: result},
}, nil
}

Expand Down Expand Up @@ -278,14 +278,14 @@ func main() {

// TODO(ROX-12971): Replace with real scanner
scanner := nodescanv2.FakeNodeScanner{}
nodeScansC := manageNodeScanLoop(ctx, env.NodeRescanInterval.DurationSetting(), &scanner)
// multiplex producers (nodeScansC) into the output channel (sensorC)
nodeInventoriesC := manageNodeScanLoop(ctx, env.NodeRescanInterval.DurationSetting(), &scanner)
// multiplex producers (nodeInventoriesC) into the output channel (sensorC)
go func() {
for {
select {
case <-ctx.Done():
return
case sensorC <- <-nodeScansC:
case sensorC <- <-nodeInventoriesC:
}
}
}()
Expand Down
8 changes: 4 additions & 4 deletions compliance/collection/nodescanv2/fake_nodescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ var (
log = logging.LoggerForModule()
)

// FakeNodeScanner can be used to send fake messages that would be emitted by NodeScanV2
// FakeNodeScanner can be used to send fake messages that would be emitted by NodeInventory
type FakeNodeScanner struct {
}

// Scan returns a fake message in the same format a real NodeScanV2 would produce
func (f *FakeNodeScanner) Scan(nodeName string) (*storage.NodeScanV2, error) {
// Scan returns a fake message in the same format a real NodeInventory would produce
func (f *FakeNodeScanner) Scan(nodeName string) (*storage.NodeInventory, error) {
log.Infof("Generating fake scan result message...")
msg := &storage.NodeScanV2{
msg := &storage.NodeInventory{
NodeId: "",
NodeName: nodeName,
ScanTime: timestamp.TimestampNow(),
Expand Down
6 changes: 3 additions & 3 deletions compliance/collection/nodescanv2/nodescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (

// NodeScanner defines an interface for V2 NodeScanning
type NodeScanner interface {
Scan(nodeName string) (*storage.NodeScanV2, error)
Scan(nodeName string) (*storage.NodeInventory, error)
}

// NodeScan is the V2 NodeScanning implementation
type NodeScan struct {
}

// Scan scans the current node and returns the results as storage.NodeScanV2 object
func (n *NodeScan) Scan(nodeName string) (*storage.NodeScanV2, error) {
// Scan scans the current node and returns the results as storage.NodeInventory object
func (n *NodeScan) Scan(nodeName string) (*storage.NodeInventory, error) {
return nil, errors.New("Not implemented")
}
2 changes: 1 addition & 1 deletion compliance/collection/nodescanv2/nodescan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ func (n *NodeScanSuite) TestMessageFormat() {
fns, err := (&FakeNodeScanner{}).Scan("someNode")
n.Nil(err)
n.NotNil(fns)
n.IsType(&storage.NodeScanV2{}, fns)
n.IsType(&storage.NodeInventory{}, fns)
}
266 changes: 133 additions & 133 deletions generated/internalapi/central/sensor_events.pb.go

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions generated/internalapi/sensor/compliance_iservice.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading