Skip to content
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

add manager type to nodemanager process node flow #3630

Closed
wants to merge 10 commits into from

Conversation

vjeffrey
Copy link

@vjeffrey vjeffrey commented May 11, 2020

🔩 Description: What code changed, and why?

this change adds the manager type to the nodemanager process node flow, meaning

  • we can assign any node which is coming through ingest service the manager "chef" since we know that node is managed by chef
  • any node that is automate or aws-ec2 or azure-api etc will get the type of the processnode message, meaning that we dont have to look up the type of the manager based on the id and save an extra db call

i also added a format tags bit. we have a troublesome tag example in the chef-load codebase used for testing, and it seems we fail to list nodes when this troublesome tag exists in the db, because we choke on the json (the tag value in question is Dot.Comma,Big;\"Trouble)

⛓️ Related Resources

#3515

👍 Definition of Done

manager type is on process node message
nodes managed by chef are labelled as such

👟 How to Build and Test the Change

rebuild compliance, ingest, nodemanager
load some nodes (chef_load_nodes, load_compliance_reports, chef_load_compliance_nodes)
see the manager type for the nodes is correct!

✅ Checklist

Aha! Link: https://chef.aha.io/features/SH-1835

@vjeffrey vjeffrey requested a review from a team May 11, 2020 15:34
@vjeffrey vjeffrey marked this pull request as ready for review May 11, 2020 17:33
@@ -98,6 +98,7 @@ func gatherInfoForNode(msg message.ChefRun) (*manager.NodeMetadata, error) {
EndTime: timestamp,
Status: status,
},
ManagerType: "chef",
Copy link
Contributor

Choose a reason for hiding this comment

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

To have the managed type of "Chef" does that include Effortless/Chef Solo Runs?

Copy link
Author

Choose a reason for hiding this comment

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

right now this code is just putting "chef" on anything coming through the ingest service -- so ya those would also get "chef" as the manager

@lancewf
Copy link
Contributor

lancewf commented May 11, 2020

I have to think about this more but this test is ensuring we are only filtering on nodes with an empty Manager. Where before an empty manager meant it was a client runs node.

@lancewf
Copy link
Contributor

lancewf commented May 11, 2020

Here is the code where we only filter nodes that have an empty manager.

condition = condition + " OR n.manager <> ''"

@lancewf
Copy link
Contributor

lancewf commented May 11, 2020

I just confirmed locally that this does break the project filtering on the nodemanager APIs for client run nodes. I wonder why the cypress tests did not fail 🤷

@vjeffrey
Copy link
Author

vjeffrey commented May 11, 2020

oof im glad you thought of testing that!

we can extend the code to say empty of 'chef' manager..but :( that the test didn't fail

@vjeffrey
Copy link
Author

i also need to update the ui call for scan job nodes, bc right now it is excluding nodes with empty string manager, which means all the chef nodes would show up there without further changes

Victoria Jeffrey added 10 commits May 17, 2020 13:52
Signed-off-by: Victoria Jeffrey <[email protected]>
Signed-off-by: Victoria Jeffrey <[email protected]>
Signed-off-by: Victoria Jeffrey <[email protected]>
Signed-off-by: Victoria Jeffrey <[email protected]>
Signed-off-by: Victoria Jeffrey <[email protected]>
@vjeffrey vjeffrey changed the base branch from master to vj/nodes-proj-filt May 17, 2020 21:11
@@ -316,7 +316,7 @@ func (srv *Server) validateNodeUpdate(ctx context.Context, in *nodes.Node) error
switch node.Manager {
case "aws-api", "azure-api", "gcp-api":
return &errorutils.InvalidError{Msg: fmt.Sprintf("invalid option. unable to update %s node", in.Manager)}
case "":
case "", "chef":
Copy link
Author

@vjeffrey vjeffrey May 17, 2020

Choose a reason for hiding this comment

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

this ensures we cannot update the name or tags of an ingested node

@@ -690,7 +690,7 @@ func validateNodeFilters(filters []*common.Filter) error {
func isValidNodeManagerType(item string) bool {
switch item {
// empty string covers legacy nodes (nodes created before we started associating all manual nodes with "automate" as a manager and nodes brought over from a1)
case "aws-ec2", "aws-api", "azure-api", "azure-vm", "automate", "":
case "aws-ec2", "aws-api", "azure-api", "azure-vm", "automate", "gcp-api", "chef":
Copy link
Author

Choose a reason for hiding this comment

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

should've added gcp-api a long time ago!

@@ -127,20 +127,12 @@ func (db *DB) ProcessIncomingNode(node *manager.NodeMetadata) error {
return errors.Wrap(err, "ProcessIncomingNode unable to marshal projects data")
}

var mgrType string
if node.ManagerId != "" {
Copy link
Author

Choose a reason for hiding this comment

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

now that the type is included in the report, we dont have to look up the type in the db

@@ -521,6 +521,7 @@ func (t *InspecJobTask) reportIt(ctx context.Context, job *types.InspecJob, cont
report.SourceRegion = job.TargetConfig.TargetBaseConfig.Region
report.SourceAccountId = job.SourceAccountID
report.AutomateManagerId = job.ManagerID
report.AutomateManagerType = job.ManagerType
Copy link
Author

Choose a reason for hiding this comment

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

this is where we stick the manager type on the report

@@ -90,6 +91,10 @@ func gatherInfoForNode(in message.Compliance) (*manager.NodeMetadata, error) {
tags = append(tags, &common.Kv{Key: "environment", Value: in.Report.GetEnvironment()})
}

mgrType := in.Report.GetAutomateManagerType()
if in.Report.GetSourceFqdn() != "" {
Copy link
Author

Choose a reason for hiding this comment

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

get the type on the report, but if the sourcefqdn is not empty string then we know it's managed by chef

@vjeffrey
Copy link
Author

closing this til i can get back to it

@vjeffrey vjeffrey closed this May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants