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

Make flowmachine table cache owner #5189

Merged
merged 11 commits into from
Jun 20, 2022
Merged

Make flowmachine table cache owner #5189

merged 11 commits into from
Jun 20, 2022

Conversation

greenape
Copy link
Member

@greenape greenape commented May 31, 2022

Closes #4714

I have:

  • Formatted any Python files with black
  • Brought the branch up to date with master
  • Added any relevant Github labels
  • Added tests for any new additions
  • Added or updated any relevant documentation
  • Added an Architectural Decision Record (ADR), if appropriate
  • Added an MPLv2 License Header if appropriate
  • Updated the Changelog

Description

  1. Makes the flowmachine user always named flowmachine (you can create other users, but there shall always be a flowmachine user
  2. Adds, as a post action on writing to cache, an ownership change of the newly created table to flowmachine.

@greenape greenape added bug Something isn't working FlowMachine Issues related to FlowMachine labels May 31, 2022
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #5189 (2d7d2c1) into master (2ea7f5c) will decrease coverage by 0.00%.
The diff coverage is 96.29%.

@@            Coverage Diff             @@
##           master    #5189      +/-   ##
==========================================
- Coverage   93.93%   93.93%   -0.01%     
==========================================
  Files         276      276              
  Lines       10640    10646       +6     
  Branches     1271     1274       +3     
==========================================
+ Hits         9995    10000       +5     
  Misses        518      518              
- Partials      127      128       +1     
Impacted Files Coverage Δ
flowmachine/flowmachine/core/cache.py 92.69% <96.15%> (-0.25%) ⬇️
flowmachine/flowmachine/core/query.py 95.94% <100.00%> (+0.01%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@greenape greenape requested a review from jc-harrison May 31, 2022 11:48
@greenape greenape added the ready-to-merge Label indicating a PR is OK to automerge label Jun 10, 2022
@cypress
Copy link

cypress bot commented Jun 10, 2022



Test summary

43 0 0 0Flakiness 0


Run details

Project FlowAuth
Status Passed
Commit 2d7d2c1
Started Jun 20, 2022 11:32 AM
Ended Jun 20, 2022 11:44 AM
Duration 12:42 💡
OS Linux Debian - 10.5
Browser Electron 100

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@greenape greenape force-pushed the reown-tables branch 3 times, most recently from 9c47782 to 8843c73 Compare June 13, 2022 09:10
Copy link
Member

@jc-harrison jc-harrison left a comment

Choose a reason for hiding this comment

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

Can also remove the FLOWMACHINE_FLOWDB_USER env from 'development_environment', and the secret from secrets-quickstart.sh.

@@ -199,7 +193,7 @@ psql --dbname="$POSTGRES_DB" -c "
obj record;
Copy link
Member

Choose a reason for hiding this comment

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

Presumably this trigger is no longer required?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've kept it in to allow for the possibility of tables getting created thru routes other than flowmachine that we'd still want to be managed. That said, I'm not sure there's really an eventuality where that arises and they're also in the cache table.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we would necessarily want to change ownership of tables created through routes other than flowmachine, since the ownership change is specifically so that all flowmachine instances can access flowmachine-generated cache tables. Without an obvious situation where this might occur, I think it's just as plausible that we'd want the opposite - that tables created through some unforeseen route should remain owned by the user that created them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree.

@greenape
Copy link
Member Author

Can also remove the FLOWMACHINE_FLOWDB_USER env from 'development_environment', and the secret from secrets-quickstart.sh.

Need to keep these, because flowmachine still has a configurable username, it just happens to be flowmachine in these examples. Perhaps we should mandate it to flowmachine in container though?

@jc-harrison
Copy link
Member

Can also remove the FLOWMACHINE_FLOWDB_USER env from 'development_environment', and the secret from secrets-quickstart.sh.

Need to keep these, because flowmachine still has a configurable username, it just happens to be flowmachine in these examples. Perhaps we should mandate it to flowmachine in container though?

Ah, I see. I suppose the question is: would we ever want the flowmachine container to use a postgres user other than flowmachine (perhaps, if individual users wanted to spin up their own flowmachine server and API?). In that situation, the flowmachine service would need a different FLOWMACHINE_FLOWDB_PASSWORD as well.

But for a standard deployment I think we'd always want the flowmachine container to use the flowmachine user. Maybe we could set flowmachine as the default in the container but allow overriding via the env?

@greenape greenape force-pushed the reown-tables branch 2 times, most recently from e4cde97 to 6b27283 Compare June 17, 2022 12:09
@jc-harrison
Copy link
Member

I've been thinking about the exception-catching business, and whether catching BaseException is the right thing to do here. I wonder whether it's more appropriate to cancel a query on KeyboardInterrupt than to error it, given that an ERRORED query indicates something went wrong when executing the query and it therefore can't be re-run without a manual reset, whereas CANCELLED indicates query execution was stopped but not due to the query itself, and the query can be re-run without manual intervention. So perhaps:

try:
    <run query>
except Exception as exc:
    q_state_machine.raise_error()
    raise exc
finally:
    if not q_state_machine.is_finished_executing:
        q_state_machine.cancel()

(i.e. if the query is still in a blocking state when it should have finished, but no Exception was raised, cancel it).

Copy link
Member

@jc-harrison jc-harrison left a comment

Choose a reason for hiding this comment

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

👍

@mergify mergify bot merged commit 922b66d into master Jun 20, 2022
@mergify mergify bot deleted the reown-tables branch June 20, 2022 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working FlowMachine Issues related to FlowMachine ready-to-merge Label indicating a PR is OK to automerge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flowmachine should own all cache tables
2 participants