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

postgres: create dynamic metadata #11065

Closed
cpakulski opened this issue May 5, 2020 · 9 comments · Fixed by #11620
Closed

postgres: create dynamic metadata #11065

cpakulski opened this issue May 5, 2020 · 9 comments · Fixed by #11620
Assignees

Comments

@cpakulski
Copy link
Contributor

Create dynamic metadata when parsing Postgres messages (similar to mySQL). The metadata will indicate an operation (create, delete, insert, etc) and resource on which the operation will be performed.

The metadata may be used by RBAC or routing of queries to specific instances of Postgres based on operation type.

Ref: https://www.envoyproxy.io/docs/envoy/latest/configuration/advanced/well_known_dynamic_metadata

@cpakulski
Copy link
Contributor Author

Please assign it to me.

@ahachete
Copy link

ahachete commented May 5, 2020

This would be very helpful.

What kind of metadata do you plan to expose, do you have an initial design for it? Happy to provide feedback if that could help :)

@cpakulski
Copy link
Contributor Author

@ahachete
Copy link

ahachete commented May 5, 2020

I checked that, and left me with some doubts. For example:

  • <table.db>. What if the operation references more than one table, like in a JOIN query, subselect or CTE? Maybe should be an array?
  • [] (A list of strings representing the operations executed on the resource. Operations can be one of insert/update/select/drop/delete/create/alter/show). We should determine which operations apply to Postgres. Actually, as we found with the monitoring statistics, there might be combined operations (for example a CTE that reads data and then inserts, how would you categorize that?).

Moreover, how do you plan to parse, with the SQL parser already available in Envoy? It would be interesting to see how it would handle Postgres queries, but any work in this direction will be extremely helpful for this and other future goals that require SQL parsing.

@cpakulski
Copy link
Contributor Author

Moreover, how do you plan to parse, with the SQL parser already available in Envoy? It would be interesting to see how it would handle Postgres queries, but any work in this direction will be extremely helpful for this and other future goals that require SQL parsing.

Yes, that was the idea - to start with SQL parser available in Envoy and extend it when required.

<table.db>. What if the operation references more than one table, like in a JOIN query, subselect or CTE? Maybe should be an array?
[] (A list of strings representing the operations executed on the resource. Operations can be one of insert/update/select/drop/delete/create/alter/show). We should determine which operations apply to Postgres. Actually, as we found with the monitoring statistics, there might be combined operations (for example a CTE that reads data and then inserts, how would you categorize that?).

Very valid points. I suggest that we join forces and work on document summarizing use cases and describing the logic how to handle non-trivial queries.

@ahachete
Copy link

ahachete commented May 5, 2020

Yes, perfect. Feel free to create and share a document, we can work there.

@cpakulski
Copy link
Contributor Author

/assign @cpakulski

lizan pushed a commit that referenced this issue Jun 11, 2020
…es (#11368)

Description:
Created _sqlutils_ library to be shared for common functionality between SQL filters. 
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in #11065. 

Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected

Testing:
Added unit tests.

Docs Changes:
No.

Release Notes:
No.

Fixes: #11320

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
arthuryan-k pushed a commit to arthuryan-k/envoy that referenced this issue Jun 15, 2020
…es (envoyproxy#11368)

Description:
Created _sqlutils_ library to be shared for common functionality between SQL filters.
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065.

Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected

Testing:
Added unit tests.

Docs Changes:
No.

Release Notes:
No.

Fixes: envoyproxy#11320

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: Arthur Yan <arthuryan@google.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this issue Jun 24, 2020
…es (envoyproxy#11368)

Description:
Created _sqlutils_ library to be shared for common functionality between SQL filters. 
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. 

Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected

Testing:
Added unit tests.

Docs Changes:
No.

Release Notes:
No.

Fixes: envoyproxy#11320

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
songhu pushed a commit to songhu/envoy that referenced this issue Jun 25, 2020
…es (envoyproxy#11368)

Description:
Created _sqlutils_ library to be shared for common functionality between SQL filters. 
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. 

Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected

Testing:
Added unit tests.

Docs Changes:
No.

Release Notes:
No.

Fixes: envoyproxy#11320

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
@stale
Copy link

stale bot commented Jun 26, 2020

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 26, 2020
@cpakulski
Copy link
Contributor Author

Work in progress.

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jun 30, 2020
yashwant121 pushed a commit to yashwant121/envoy that referenced this issue Jul 24, 2020
…es (envoyproxy#11368)

Description:
Created _sqlutils_ library to be shared for common functionality between SQL filters. 
mysql and postgres filters will use that library to create filter metadata based on SQL query.
mysql filter was already producing metadata but postges will use the new library as described in envoyproxy#11065. 

Risk Level:
Low: No new functionality has been added and only mysql_proxy filter is affected

Testing:
Added unit tests.

Docs Changes:
No.

Release Notes:
No.

Fixes: envoyproxy#11320

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
lizan pushed a commit that referenced this issue Jul 29, 2020
Create metadata similar to MySQL based on SQL query sent by Postgres client. The metadata may be used by other filters like RBAC.

Risk Level: Low. 
Testing: Added unit tests.
Docs Changes: Yes - updated Postgres section.
Release Notes: Yes.

Fixes #11065

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this issue Aug 7, 2020
Create metadata similar to MySQL based on SQL query sent by Postgres client. The metadata may be used by other filters like RBAC.

Risk Level: Low. 
Testing: Added unit tests.
Docs Changes: Yes - updated Postgres section.
Release Notes: Yes.

Fixes envoyproxy#11065

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this issue Aug 7, 2020
Create metadata similar to MySQL based on SQL query sent by Postgres client. The metadata may be used by other filters like RBAC.

Risk Level: Low.
Testing: Added unit tests.
Docs Changes: Yes - updated Postgres section.
Release Notes: Yes.

Fixes envoyproxy#11065

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: chaoqinli <chaoqinli@google.com>
chaoqin-li1123 pushed a commit to chaoqin-li1123/envoy that referenced this issue Aug 7, 2020
Create metadata similar to MySQL based on SQL query sent by Postgres client. The metadata may be used by other filters like RBAC.

Risk Level: Low.
Testing: Added unit tests.
Docs Changes: Yes - updated Postgres section.
Release Notes: Yes.

Fixes envoyproxy#11065

Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
Signed-off-by: chaoqinli <chaoqinli@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants