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

Intentions module input configuration #987

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

noejbrown
Copy link
Contributor

Change: added new configuration for module_input "intentions" and updated necessary module input dependencies

Commits :

  • Added intentions monitor configuration and test
  • Added intentions services configuration for source_services and destination_services used in the "intentions" block
  • Added intentions module input configuration and test
  • Updated module_input.go and module_input_test.go to include the new module_input "intentions"
Sample "intentions" module_input
task {
	name = "module_input_task"
	module = "..."
	condition "schedule" {
		cron = "* * * * * * *"
	}
	module_input "intentions" {
		datacenter = "datacenter"
		namespace = "namespace"
		source_services {
			regexp = "^web.*"
		}
		destination_services {
			regexp = "^api.*"
		}
	}
}`

@noejbrown noejbrown requested a review from a team July 8, 2022 17:49
@noejbrown noejbrown requested a review from a team as a code owner July 8, 2022 17:49
@noejbrown noejbrown requested review from a team, mdeggies, alvin-huang and hashi-derek and removed request for a team July 8, 2022 17:49
@noejbrown noejbrown closed this Jul 8, 2022
@noejbrown noejbrown reopened this Jul 8, 2022
@noejbrown noejbrown marked this pull request as draft July 8, 2022 17:55
@noejbrown noejbrown changed the base branch from main to changelog-defaultservicename July 8, 2022 19:05
@noejbrown noejbrown changed the base branch from changelog-defaultservicename to main July 8, 2022 19:05
@noejbrown noejbrown force-pushed the intentions-modinput branch from d45e5f1 to 9eec5ed Compare July 8, 2022 20:14
@noejbrown
Copy link
Contributor Author

Did a rebase, this change does not require release engineers to review anymore. Removing you all as reviewers thanks.

@noejbrown noejbrown removed request for mdeggies, alvin-huang and a team July 8, 2022 20:18
@noejbrown noejbrown marked this pull request as ready for review July 11, 2022 14:14
config/module_input_test.go Show resolved Hide resolved
config/monitor_intentions_test.go Outdated Show resolved Hide resolved
@hashi-derek
Copy link
Member

This PR looks good, but not marking it as approved yet. We will utilize this as the feature branch for all intentions work, so there will be other PRs merged into this.

config/intentions_service.go Outdated Show resolved Hide resolved
config/intentions_service.go Outdated Show resolved Hide resolved
return ": (*IntentionsServicesConfig)(nil)"
}

if len(c.Names) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about the correctness of this logic
I understand that we want to specify either Names OR Regex, but that is business logic, and the struct doesn't know about this restriction. Therefore, IF I create an IntentionsServicesConfig object with both Names and Regex defined, I expect the GoString() method to return a string with both fields, not just Names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic behind this is for the expected use case that both fields wouldn't be defined. If you create IntentionsServicesConfig object with both field defined, the validate function that is prior to this would fail. I could see putting an error message here instead if both are configured but showing both didn't make sense to me because the output would be :

&IntentionsModuleInputConfig{&IntentionsMonitorConfig{Datacenter:dc, Namespace:namespace, Source Services: Names: Regexp:^web.*, Destination Services: Names: Regexp:^api.*}}

Could you explain more what the use case for showing both names and regexp would be? I think it would steer people into the wrong direction that you could use both and lead to test failure.

config/intentions_service.go Outdated Show resolved Hide resolved
config/intentions_service.go Outdated Show resolved Hide resolved
noejbrown and others added 10 commits July 15, 2022 08:33
Edited test name to be correct and more reflective of what it does : "regexp_same"
Added additional test case for "happy_path_different_type" and added back previous test case. This additional test case, test that two different paths (on being Intentions module input) merge.
Changed test name to "regexp_same"
Readability change

Co-authored-by: AJ Jwair <[email protected]>
Readability change

Co-authored-by: AJ Jwair <[email protected]>
Readability change

Co-authored-by: AJ Jwair <[email protected]>
Readability change

Co-authored-by: AJ Jwair <[email protected]>
Change Sprintf to be one line in GoString
Change Sprintf to be one line in GoString
@noejbrown noejbrown force-pushed the intentions-modinput branch from 2a6495d to a733ece Compare July 15, 2022 12:36
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.

3 participants