Skip to content

Commit

Permalink
Passing the base platform name to the nodemanager (#3612)
Browse files Browse the repository at this point in the history
Signed-off-by: Lance Finfrock <[email protected]>
  • Loading branch information
lancewf authored May 6, 2020
1 parent 0318ae6 commit 154753b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
12 changes: 8 additions & 4 deletions components/ingest-service/backend/chef_client_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (ccr *ChefClientRun) initializeNodeInfo() (sharedNodeInfo NodeInfo, err err
UptimeSeconds: int64(uptimeSeconds),
OrganizationName: ccr.OrganizationName,
Environment: ccr.NodePayload.ChefEnvironment,
Platform: getPlatformWithVersion(ccr.NodePayload),
Platform: ccr.PlatformWithVersion(),
PlatformFamily: EmptyStringIfNil(ccr.NodePayload.Automatic["platform_family"]),
PlatformVersion: EmptyStringIfNil(ccr.NodePayload.Automatic["platform_version"]),
// Tags ccr. TODO: Is this compliance tags?
Expand Down Expand Up @@ -286,6 +286,10 @@ func (ccr *ChefClientRun) initializeNodeInfo() (sharedNodeInfo NodeInfo, err err
return // nolint: nakedret
}

func (ccr *ChefClientRun) Platform() string {
return EmptyStringIfNil(ccr.NodePayload.Automatic["platform"])
}

// ChefVersion Returns a chef version string retrieved from automatic attributes or an empty string if it is not present
func (ccr *ChefClientRun) ChefVersion() string {
chefPackages := extractMapOrEmpty(ccr.NodePayload.Automatic, "chef_packages")
Expand Down Expand Up @@ -492,9 +496,9 @@ func countNumberOfValueObject(object interface{}) int {
return count
}

func getPlatformWithVersion(nodePayload NodePayload) string {
platform := EmptyStringIfNil(nodePayload.Automatic["platform"])
platformVersion := EmptyStringIfNil(nodePayload.Automatic["platform_version"])
func (ccr *ChefClientRun) PlatformWithVersion() string {
platform := ccr.Platform()
platformVersion := EmptyStringIfNil(ccr.NodePayload.Automatic["platform_version"])

platformAndVersion := ""

Expand Down
2 changes: 2 additions & 0 deletions components/ingest-service/pipeline/message/chef_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type ChefRun struct {
NodeRun backend.Run
NodeAttribute backend.NodeAttribute
BulkableRequests []elastic.BulkableRequest
Platform string
Ctx context.Context
errc chan<- error
}
Expand All @@ -43,6 +44,7 @@ func NewChefRun(ctx context.Context, run *chef.Run, err chan<- error) ChefRun {
backend.Run{},
backend.NodeAttribute{},
[]elastic.BulkableRequest{},
"",
ctx,
err,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func ChefRunTransmogrify(in <-chan message.ChefRun, out chan<- message.ChefRun,
continue
}

// Needed for the nodemanager because the platform field is combined with the version.
msg.Platform = ccr.Platform()

message.PropagateChefRun(out, &msg)
}
close(out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func nodeManagerPublisher(in <-chan message.ChefRun, nodeManagerClient manager.N
continue
}

nodeMetadata, err := gatherInfoForNode(msg.Node)
nodeMetadata, err := gatherInfoForNode(msg)
if err != nil {
log.Errorf("unable parse node data to be send to manager. aborting attempt to send info to mgr for node %s -- %v", msg.Node.NodeName, err)
out <- msg
Expand All @@ -51,7 +51,9 @@ func nodeManagerPublisher(in <-chan message.ChefRun, nodeManagerClient manager.N
return out
}

func gatherInfoForNode(node backend.Node) (*manager.NodeMetadata, error) {
func gatherInfoForNode(msg message.ChefRun) (*manager.NodeMetadata, error) {
node := msg.Node

// convert node check in time to proto timestamp
timestamp, err := ptypes.TimestampProto(node.Checkin)
if err != nil {
Expand Down Expand Up @@ -82,7 +84,7 @@ func gatherInfoForNode(node backend.Node) (*manager.NodeMetadata, error) {
return &manager.NodeMetadata{
Uuid: node.EntityUuid,
Name: node.NodeName,
PlatformName: node.PlatformFamily,
PlatformName: msg.Platform,
PlatformRelease: node.PlatformVersion,
LastContact: timestamp,
SourceId: node.CloudID,
Expand Down

0 comments on commit 154753b

Please sign in to comment.