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

Create all FlowExporter resources in a function #2829

Closed
heanlan opened this issue Sep 23, 2021 · 9 comments · Fixed by #2854
Closed

Create all FlowExporter resources in a function #2829

heanlan opened this issue Sep 23, 2021 · 9 comments · Fixed by #2854
Labels
area/flow-visibility/exporter Issues or PRs related to the Flow Exporter functions in the Agent kind/design Categorizes issue or PR as related to design.

Comments

@heanlan
Copy link
Contributor

heanlan commented Sep 23, 2021

Describe what you are trying to solve
In antrea/cmd/antrea-agent/agent.go, we create denyConnStore, conntrackConnStore, flowExporter separately. We can try to have a function in flowexporter package to create all the flowexporter resources. Reference to: #2360 (comment)

Describe the solution you have in mind
As there are a lot of variables required by NewConntrackConnectionStore(), NewFlowExporter(), we might consider to group some of the variables, in order to avoid to pass too many parameters to the creating-resources function.

@heanlan heanlan added kind/design Categorizes issue or PR as related to design. area/flow-visibility/exporter Issues or PRs related to the Flow Exporter functions in the Agent labels Sep 23, 2021
@heanlan heanlan changed the title Integrate creating all FlowExporter resources in a function Create all FlowExporter resources in a function Sep 23, 2021
@srikartati
Copy link
Member

This is not a major change that warrants an issue IMO. Please open a PR directly or have a TODO in the code in your next PR.

@heanlan
Copy link
Contributor Author

heanlan commented Sep 23, 2021

This is not a major change that warrants an issue IMO. Please open a PR directly or have a TODO in the code in your next PR.

Got it. I thought issue can be used as a TODO, now be more aware of the usage of issues. Thanks!

@heanlan heanlan closed this as completed Sep 23, 2021
@antoninbas
Copy link
Contributor

It's fine to open an issue if you are not sure sure about the change (and wants to discuss it) or if you don't have time to tackle it in the near future.

@heanlan
Copy link
Contributor Author

heanlan commented Sep 23, 2021

It's fine to open an issue if you are not sure sure about the change (and wants to discuss it) or if you don't have time to tackle it in the near future.

Got it. Thanks Antonin.

@heanlan
Copy link
Contributor Author

heanlan commented Sep 27, 2021

There is a problem - if we want to create all the resources in a function under flowexporter package, there will be some import cycles: between flowexporter and connections package, between flowexporter and priorityqueue package.
e.g. we need to call methods in connections package in line, while connections package imports flowexporter in line.

Do we have any solutions to handle the import cycle problems? @antoninbas @srikartati

@heanlan heanlan reopened this Sep 27, 2021
@srikartati
Copy link
Member

In antrea/cmd/antrea-agent/agent.go, we create denyConnStore, conntrackConnStore, flowExporter separately. We can try to have a function in flowexporter package to create all the flowexporter resources. Reference to: #2360 (comment)

How can denyConnStore is grouped with conntrackConnStore? denyConnStore is needed for initialization of networkPolicyController, and networkPolicyController is needed for conntrackConnStore.

@heanlan
Copy link
Contributor Author

heanlan commented Sep 28, 2021

In antrea/cmd/antrea-agent/agent.go, we create denyConnStore, conntrackConnStore, flowExporter separately. We can try to have a function in flowexporter package to create all the flowexporter resources. Reference to: #2360 (comment)

How can denyConnStore is grouped with conntrackConnStore? denyConnStore is needed for initialization of networkPolicyController, and networkPolicyController is needed for conntrackConnStore.

I'm thinking we can declare denyConnStore this variable before we initialize networkPolicyController, and actually assign value for this variable in the function we want to create, not sure whether that would work or not...

@srikartati
Copy link
Member

I'm thinking we can declare denyConnStore this variable before we initialize networkPolicyController, and actually assign value for this variable in the function we want to create, not sure whether that would work or not...

I think as a first step, combining priority queue and connection store initializations separately for denyConnStore and conntrackConnStore is better. You could try placing those in the connections package.

@heanlan
Copy link
Contributor Author

heanlan commented Sep 28, 2021

I think as a first step, combining priority queue and connection store initializations separately for denyConnStore and conntrackConnStore is better. You could try placing those in the connections package.

Yes, the first step makes a lot of sense. I have done that in the PR.
If we want a step further, i think at least we cannot wrap all into the current flowexporter package, due to the import cycle problems. I'll try to think about anything else we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/flow-visibility/exporter Issues or PRs related to the Flow Exporter functions in the Agent kind/design Categorizes issue or PR as related to design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants