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

allow imported resources to be path expanded and more state reading #979

Merged
merged 6 commits into from
Apr 12, 2024

Conversation

jhsinger-klotho
Copy link
Contributor

adds checks to ensure we are choosing paths which dont change properties of imported resources
ensures that we dont only consider direct edges for imported resource path expansion
allows resources to deny themselves from being used in specific path selection classifications
adds the ability to read state for fields that need to be translated to field Refs or resource ids

making sure imports work with more resources

Standard checks

  • Unit tests: Any special considerations?
  • Docs: Do we need to update any docs, internal or public?
  • Backwards compatibility: Will this break existing apps? If so, what would be the extra work required to keep them working?

@gordon-klotho gordon-klotho self-requested a review April 9, 2024 19:56
Copy link
Contributor

@gordon-klotho gordon-klotho left a comment

Choose a reason for hiding this comment

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

Only open question is on DenyClassifications. Everything else is 👍

@@ -91,7 +91,7 @@ func (action *operationalResourceAction) createUniqueResources(resource *constru
return err
}
}
if len(uids) == 1 {
if len(uids) == 1 && uids[0].Matches(resource.ID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If neither of these are template resource ids (ones without names), then IMO == is much clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the selector may not have a name

Copy link
Contributor

Choose a reason for hiding this comment

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

Which is the selector? uids comes from downstream so they're real resources. If resource.ID is the selector, then it needs to be the receiver (per the godoc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah youre right neither of these is the selector, i can change it to ==

@@ -20,6 +21,58 @@ type (
}
)

// checkDoesNotModifyImportedResource checks if there is an imported resource that would be modified due to the edge
// If there is an edge rule modifying the resource then we consider the edge to be invalid
func checkDoesNotModifyImportedResource(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the "does not" kinda throws me for a loop - usually I like to keep functions in the positive (and properties, when the default value isn't important)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can change the naming and make it return the inverse then

errs = errors.Join(errs, err)
return
}
if !doesNotModifyImport {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit continued: this further leans me towards the function should be checkDoesModify... (positive) so it doesn't need to be negated

return nil
}

func (p propertyCorrelator) checkValue(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this function could use either a better name or some documentation on what it does. Seems like it does more than checking, since I see a SetProperty and AddVertex (write operations).

AsSource []PathSatisfactionRoute `json:"as_source" yaml:"as_source"`
AsTarget []PathSatisfactionRoute `json:"as_target" yaml:"as_target"`
AsSource []PathSatisfactionRoute `json:"as_source" yaml:"as_source"`
DenyClassifications []string `yaml:"deny_classifications"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand what DenyClassifications is used for / what problems it solves. Could you document and add a test case (either in path_selection or as a functional test) demonstrating it its use-case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was just carry over from the other stuff so can remove. But it was a way of making sure subnets arent used in permissions path solving and iam roles arent used in network path solving since they were getting connected by the ec2 launch templates security group. Since this isnt tackling dynamic port mappings anymore i can remove it

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you, but the choices IMO are: (1) keep it in and add tests/docs for it, (2) split it out (either to be reimplemented later or keep around as an incomplete PR)

Copy link
Contributor

@gordon-klotho gordon-klotho left a comment

Choose a reason for hiding this comment

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

I'd prefer if you do a little more to pick one or the other for DenyClassification, but not enough to block the PR.

AsSource []PathSatisfactionRoute `json:"as_source" yaml:"as_source"`
AsTarget []PathSatisfactionRoute `json:"as_target" yaml:"as_target"`
AsSource []PathSatisfactionRoute `json:"as_source" yaml:"as_source"`
DenyClassifications []string `yaml:"deny_classifications"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you, but the choices IMO are: (1) keep it in and add tests/docs for it, (2) split it out (either to be reimplemented later or keep around as an incomplete PR)

@jhsinger-klotho jhsinger-klotho merged commit 992a83c into main Apr 12, 2024
6 checks passed
@jhsinger-klotho jhsinger-klotho deleted the more_properties_and_imports_path branch April 12, 2024 19:19
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