Commit Graph

2673 Commits

Author SHA1 Message Date
Rakesh Emmadi
9ef603360c server: generalize schema cache building (#496)
Co-authored-by: Vamshi Surabhi <vamshi@hasura.io>
Co-authored-by: Vladimir Ciobanu <admin@cvlad.info>
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
GitOrigin-RevId: 9d631878037637f3ed2994b5d0525efd978f7b8f
2021-02-14 06:08:46 +00:00
Phil Freeman
7fffc11077 Caching, Rate Limiting, Metrics & Session Variable Improvements (#376)
* server: use a leaky bucket algorithm for bytes-per-second cache rate limiting

* Use evalsha properly

* Adds redis cache limit parameters to PoliciesConfig

* Loads Leaky Bucket Script On Server Start

* Adds more redis logging and moves cache update into lua script

* reverts setex in lua and adds notes

* Refactors cacheStore and adds max TTL and cache size limits

* Filter session vars in cache key

* WIP

* parens

* cache-clear-hander POC implementation

* cache-clear-hander POC implementation

* Pro projectId used as cache key

* POC working!

* prefixing query-response keys in redis

* Add cacheClearer to RedisScripts

* Partial implementation of cacheClearer from scripts record

* updating tests

* [automated] stylish-haskell commit

* Adds query look with up with metrics script

* Adds missing module and lua script from last commit

* Changes redis script module structure to match cache clearing branch

* minor change to lua script

* cleaning up cache clearing

* generalising JsonLog

* [automated] stylish-haskell commit

* Draft Cache Metrics Endpoint

* Adds Cache Metrics Handler

* Adds hook handler module

* Missed HandlerHook module in last commit

* glob

* Fixes redis mget bug

* Removes cache totals and changes dashes to colons in metric cache keys

* Adds query param to clear clear endpoint for deleting specific keys

* Adds query param to clear clear endpoint for deleting specific keys

* Cache Metrics on query families rather then queries

* Replace Set with nub

* Base16 Redis Hashes

* Query Family Redis Keys With Roles

* response headers for cache keys

* fixing bug in family key by excluding operation name; using hash for response header instead of entire key

* Adds query family to redis cache keys and cache clear endpoint

* Fixes queryfamily hash bug

* Moves cache endpoints to /pro

* Moved cache clear to POST

* Refactors cache clear function

* Fixes query family format bug

* Adds query cache tests and optional --redis-url flag to python test suite

* Adds session variable cache test

* Update pro changelog

* adding documentation for additional caching features

* more docs

* clearing up units of leaky bucket params

* Adds comments to leaky bucket script

* removes old todo

* Fixes session variable filtering to work with new query rootfield

* more advanced defaulting behaviour for bucket rate and capacity.

* Updates Docs

* Moves Role into QueryFamily hash

* Use Aeson for Cache Clear endpoint response

* Moves trace to bracket the leaky bucket script

* Misc review tweaks

* Adds sum type for cache clear query params

* Hardcodes RegisReplyLog log level

* Update docs/graphql/cloud/response-caching.rst

Co-authored-by: Phil Freeman <phil@hasura.io>

* new prose for rate limiting docs

* [automated] stylish-haskell commit

* make rootToSessVarPreds total

* [automated] stylish-haskell commit

* Fixes out of scope error

* Renamed _acRedis to _acCacheStore

Co-authored-by: Solomon Bothwell <ssbothwell@gmail.com>
Co-authored-by: Lyndon Maydwell <lyndon@sordina.net>
Co-authored-by: David Overton <david@hasura.io>
Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
Co-authored-by: Lyndon Maydwell <lyndon@hasura.io>
GitOrigin-RevId: dda5c1a3f902967b3d78310f950541a55fabb1b0
2021-02-13 00:06:18 +00:00
Sameer Kolhar
8655e6fd3a console: function permissions UI (#413)
GitOrigin-RevId: ccdfab19751b0d238a4ebcec59ba73a798103ca9
2021-02-12 17:02:41 +00:00
Karthikeyan Chinnakonda
8a68cc6650 server: don't expose remote schema mutations in relay
GitOrigin-RevId: 21c126bfd46a22d3b0e64d57e92d78ea3c4df9ab
2021-02-12 13:29:19 +00:00
Ikechukwu Eze
429055acc9 console: add link to manage databases page to the onboarding helper
<img width="397" alt="Screenshot 2021-02-11 at 22 17 35" src="https://user-images.githubusercontent.com/9019397/107699935-0eea8e80-6cb7-11eb-8f7f-f2894116ada6.png">
<img width="381" alt="Screenshot 2021-02-11 at 22 16 56" src="https://user-images.githubusercontent.com/9019397/107699944-10b45200-6cb7-11eb-9c70-a4e4b465bda5.png">

Co-authored-by: Aleksandra Sikora <9019397+beerose@users.noreply.github.com>
GitOrigin-RevId: 37c475cb1f7a1062c77c74ad45918684ec0406f9
2021-02-12 07:52:08 +00:00
Antoine Leblanc
1ca4034697 server: generalize execution of queries and mutations
GitOrigin-RevId: aff477a0849d4667f2f6dc6804d6ca2982e53f95
2021-02-12 03:05:05 +00:00
Antoine Leblanc
5b0fc9a365 server: update cabal dependencies
GitOrigin-RevId: a30b1dc80455059330cdae7c9084eb70552d54d0
2021-02-12 02:59:00 +00:00
Matthew Pickering
35b81f39e9 Memory performance improvements from Cherre (#518)
* Stop shutdown handler retaining the whole serveCtx

This might look like quite a strange way to write the function but it's
the only way I could get GHC to not capture `serveCtx` in the shutdown
handler.

Fixes the metadata issue in #344

* Force argumentNames

The arguments list is often empty so we end up with a lot of duplicate
thunks if this value is not forced.

* Increase sharing in nullableType and nonNullableType

The previous definitions would lead to increased allocation as it would
destory any previously created sharing. The new definition only allocate
a fresh constructor if the value is changed.

* Add memoization for field parsers

It was observed in #344 that many parsers were not being memoised which
led to an increase in memory usage. This patch generalisation memoisation so
that it works for FieldParsers as well as normal Parsers.

There can still be substantial improvement made by also memoising
InputFieldParsers but that is left for future work.

Co-authored-by: Antoine Leblanc <antoine@hasura.io>

* [automated] stylish-haskell commit

* changelog

Co-authored-by: Phil Freeman <paf31@cantab.net>
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
Co-authored-by: Phil Freeman <phil@hasura.io>
GitOrigin-RevId: 36255f77a47cf283ea61df9d6a4f9138d4e5834c
2021-02-12 01:34:56 +00:00
Anon Ray
06b599b747 server: multitenant metadata storage
The metadata storage implementation for graphql-engine-multitenant.

- It uses a centralized PG database to store metadata of all tenants (instead of per tenant database)
- Similarly, it uses a single schema-sync listener thread per MT worker (instead of listener thread per tenant) (PS: although, the processor thread is spawned per tenant)
- 2 new flags are introduced - `--metadataDatabaseUrl` and (optional) `--metadataDatabaseRetries`

Internally, a "metadata mode" is introduced to indicate an external/managed store vs a store managed by each pro-server.

To run :
- obtain the schema file (located at `pro/server/res/cloud/metadata_db_schema.sql`)
- apply the schema on a PG database
- set the `--metadataDatabaseUrl` flag to point to the above database
- run the MT executable

The schema (and its migrations) for the metadata db is managed outside the MT worker.

### New metadata

The following is the new portion of `Metadata` added :

```yaml
version: 3
metrics_config:
  analyze_query_variables: true
  analyze_response_body: false
api_limits:
  disabled: false
  depth_limit:
    global: 5
    per_role:
      user: 7
      editor: 9
  rate_limit:
    per_role:
      user:
        unique_params:
        - x-hasura-user-id
        - x-hasura-team-id
        max_reqs_per_min: 20
    global:
      unique_params: IP
      max_reqs_per_min: 10
```

- In Pro, the code around fetching/updating/syncing pro-config is removed
- That also means, `hdb_pro_catalog` for keeping the config cache is not required. Hence the `hdb_pro_catalog` is also removed
- The required config comes from metadata / schema cache

### New Metadata APIs

- `set_api_limits`
- `remove_api_limits`
- `set_metrics_config`
- `remove_metrics_config`

#### `set_api_limits`

```yaml
type: set_api_limits
args:
  disabled: false
  depth_limit:
    global: 5
    per_role:
      user: 7
      editor: 9
  rate_limit:
    per_role:
      anonymous:
         max_reqs_per_min: 10
         unique_params: "ip"
      editor:
        max_reqs_per_min: 30
        unique_params:
        - x-hasura-user-id
      user:
        unique_params:
        - x-hasura-user-id
        - x-hasura-team-id
        max_reqs_per_min: 20
    global:
      unique_params: IP
      max_reqs_per_min: 10
```

#### `remove_api_limits`

```yaml
type: remove_api_limits
args: {}
```

#### `set_metrics_config`

```yaml
type: set_metrics_config
args:
  analyze_query_variables: true
  analyze_response_body: false
```

#### `remove_metrics_config`

```yaml
type: remove_metrics_config
args: {}
```

#### TODO
- [x] on-prem pro implementation for `MonadMetadataStorage`
- [x] move the project config from Lux to pro metadata (PR: #379)
- [ ] console changes for pro config/api limits, subscription workers (cc @soorajshankar @beerose)
- [x] address other minor TODOs
  - [x] TxIso for `MonadSourceResolver`
  - [x] enable EKG connection pool metrics
  - [x] add logging of connection info when sources are added?
  - [x] confirm if the `buildReason` for schema cache is correct
- [ ] testing
- [x] 1.3 -> 1.4 cloud migration script (#465; PR: #508)
  - [x] one-time migration of existing metadata from users' db to centralized PG
  - [x] one-time migration of pro project config + api limits + regression tests from metrics API  to metadata
- [ ] integrate with infra team (WIP - cc @hgiasac)
  - [x] benchmark with 1000+ tenants + each tenant making read/update metadata query every second (PR: https://github.com/hasura/graphql-engine-mono/pull/411)
  - [ ] benchmark with few tenants having large metadata (100+ tables etc.)
  - [ ] when user moves regions (https://github.com/hasura/lux/issues/1717)
    - [ ] metadata has to be migrated from one regional PG to another
    - [ ] migrate metrics data as well ?
      - [ ] operation logs
      - [ ] regression test runs

- [ ] find a way to share the schema files with the infra team

Co-authored-by: Naveen Naidu <30195193+Naveenaidu@users.noreply.github.com>
GitOrigin-RevId: 39e8361f2c0e96e0f9e8f8fb45e6cc14857f31f1
2021-02-11 17:55:21 +00:00
Sameer Kolhar
5f6e59b4db console: team console fixes
GitOrigin-RevId: d1595d6572d6611ef1038c17d2bb46433735d096
2021-02-11 17:04:00 +00:00
Aleksandra Sikora
1967ad7e3a console: fix functions test
GitOrigin-RevId: 922ff246712ca2c1695d8c3b30d09e3cc96f8329
2021-02-11 16:10:55 +00:00
Karthikeyan Chinnakonda
0cfad08993 server: function permissions changes
GitOrigin-RevId: b0d784dd23aacd7a62cf471dd33eca869e25c13e
2021-02-11 09:44:38 +00:00
Sameer Kolhar
f5c0eb2c7d console: oss and pro console updates for team-console
Related work: **https://github.com/hasura/lux/pull/1335**

##### NOTE: These changes are split across both the oss-console and the pro-console.

- So we need these changes to make sure that the team console uses the `projectEndpoint` env var to load the console and execute the correct requests.

- The other item that was updated in this PR was that we, now, have hidden/removed all of the logout buttons on the Pro console(for Cloud alone).

Co-authored-by: Ikechukwu Eze <22247592+iykekings@users.noreply.github.com>
Co-authored-by: Aleksandra Sikora <9019397+beerose@users.noreply.github.com>
GitOrigin-RevId: 7319f49de4b7369b58c1261b7dd3c41cff9b858d
2021-02-10 18:31:07 +00:00
surendran82
76844835c1 docs: favicon change
GitOrigin-RevId: 4f695b1ad01b73abca5de6ebae74c5b9e03da09c
2021-02-10 08:19:05 +00:00
Antoine Leblanc
9b38863c73 server: change RootField so that only the DB component is existential
GitOrigin-RevId: ff620b775ea9b1c8433255705254ed9d58eba290
2021-02-09 19:30:08 +00:00
Antoine Leblanc
7760ed2d98 server: generalize top-level build functions
GitOrigin-RevId: 5ace65f702b411bf75c84e949742c7d657382fab
2021-02-09 12:48:22 +00:00
Vladimir Ciobanu
6b7b68504a server: improve the UX around SourceInfo
GitOrigin-RevId: 47f7e9b7daa3f89771dd3883e9f6050274827e27
2021-02-08 16:31:17 +00:00
Antoine Leblanc
e449cf9990 server: finish generalizing mutations
GitOrigin-RevId: 645eefadee35f1642eee805e20161417ab38b949
2021-02-08 10:40:51 +00:00
Funmilayo E. Olaiya
2793893b86 docs: add a note for export metadata json output (close #6209)
### Description
This PR adds a note for the export_metadata API output.

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components
- [x] Docs

### Related Issues
https://github.com/hasura/graphql-engine/issues/6209

### Affected pages
1. https://deploy-preview-298--hasura-docs-mono.netlify.app/graphql/core/migrations/reference/metadata-format.html
2. https://deploy-preview-298--hasura-docs-mono.netlify.app/graphql/core/api-reference/schema-metadata-api/manage-metadata.html

Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 10e1a3c3c42b2666992bb13a31fa0c2d622d1552
2021-02-08 09:12:37 +00:00
Priya Sharma
c739927618 cloud docs: add coupon and credit doc
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 414f519aae737cb639916c8c7f034149120f7800
2021-02-08 09:07:05 +00:00
Vishnu Bharathi
341837b652 ci,cli-ext: adds pkg as dev dependency and updates build instructions
Fixes https://github.com/hasura/graphql-engine/issues/6426

GitOrigin-RevId: 913a9e1de4bac7c96cbeab139e7593ee2ddc578b
2021-02-08 08:04:00 +00:00
Vishnu Bharathi
9e6f878440 ci: removes shadow-pr github workflow
GitOrigin-RevId: a831b3d5fb0d398faf39b327617a70ee37e618f4
2021-02-04 11:34:06 +00:00
Antoine Leblanc
83701fb63e server: changes to support other backends
GitOrigin-RevId: ec0ad47957ab6f9a0855623fffedb23924e7c75d
2021-02-03 16:25:17 +00:00
Karthikeyan Chinnakonda
312e56dfa6 server: support tracking of custom functions which return single row
GitOrigin-RevId: fbf99816a70e666bb9b02fca92a0ee7d419cdff8
2021-02-03 14:07:30 +00:00
Aleksandra Sikora
1bca160d8e console: fix adding database with url from env (close #457)
GitOrigin-RevId: 0a732a20556feb4d810fc20ba623a6818c2cf45d
2021-02-03 13:15:51 +00:00
Swann Moreau
c14dcd5792 pass gql requests into auth webhook POST body (#149)
* fix arg order in UserAuthentication instance [force ci]

* change the constructor name to AHGraphQLRequest

Co-authored-by: Stylish Haskell Bot <stylish-haskell@users.noreply.github.com>
Co-authored-by: Karthikeyan Chinnakonda <karthikeyan@hasura.io>
GitOrigin-RevId: fb3258f4a84efc6c730b0c6222ebd8cea1b91081
2021-02-03 07:11:39 +00:00
Shraddha Agrawal
1583fa6872 docs: update Datadog integration v2 docs
GitOrigin-RevId: a0f762bca40cdb5bea690f48625c3a3cb5ae7e89
2021-02-02 22:18:56 +00:00
hasura-bot
60613b4777 docs: add a guide on importing data from a CSV file into PG (close #494)
GITHUB_PR_NUMBER: 6225
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6225

Co-authored-by: Funmilayo E. Olaiya <35759534+codeliezel@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 232414fd293ab1a054b3fec35c7ee3743cd4686d
2021-02-02 10:44:36 +00:00
hasura-bot
bcb1ae07eb docs: add postgres retries environment variables
GITHUB_PR_NUMBER: 4287
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/4287

Co-authored-by: Toan Nguyen  <1615675+hgiasac@users.noreply.github.com>
GitOrigin-RevId: c93781cebb14255d1e04da669c6bf774738ba96f
2021-02-02 10:40:31 +00:00
hasura-bot
bd9c192cb7 docs: add section for codegen examples
GITHUB_PR_NUMBER: 4664
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/4664

Co-authored-by: Marion Schleifer <5722022+marionschleifer@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 70ec08da96a28b5081d1b8e24b2cb9c6a76922de
2021-02-02 09:39:46 +00:00
hasura-bot
0edfcd5f2c docs: add inserts to db modelling guides
GITHUB_PR_NUMBER: 5444
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/5444

Co-authored-by: Marion Schleifer <5722022+marionschleifer@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: caabc4de59abbeb7ac4d175cda330ace4196359b
2021-02-02 08:45:32 +00:00
hasura-bot
c3712067e8 docs: add a guide on how to clean up action logs (close #4935)
GITHUB_PR_NUMBER: 6229
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6229

Co-authored-by: Funmilayo E. Olaiya <35759534+codeliezel@users.noreply.github.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 54e6a3569481671610ea93c6ced6a6b42924c022
2021-02-02 08:06:10 +00:00
Shraddha Agrawal
fbf0c62ffa docs: add cloud docs for project ownership transfer
need to add screens.

Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
GitOrigin-RevId: 6a4977dff321ef01ea2dac9e937e1f4d45978a8c
2021-02-02 08:01:55 +00:00
Vishnu Bharathi
4004789106 ci: use envs instead of templating
GitOrigin-RevId: 7f83e62073a5e2ac77c06760f383a2c2c9c43098
2021-02-02 06:22:59 +00:00
Vijay Prasanna
52aa55904b console: filter custom functions with table args from "Untracked custom functions" list (close #6438)
GitOrigin-RevId: c4bb6950872ff2e75054cb64ce7f91fb68de0767
2021-02-01 15:03:14 +00:00
Karthikeyan Chinnakonda
94a886ee94 server: fix mutation functions not being exposed to admin when function permissions are inferred
GitOrigin-RevId: 7d8031341351bdbf25d4244ce57d4f9396dde437
2021-02-01 12:58:31 +00:00
Ikechukwu Eze
df19b7d654 console: add onboarding docs helper (#355)
GitOrigin-RevId: b60670a3e72b5ec27e63571779c76421b23caf3d
2021-02-01 10:09:47 +00:00
Karthikeyan Chinnakonda
05f21a2768 server: fix the FromJSON instance of FunctionPermissionsCtx
GitOrigin-RevId: 506d654ef9cad95ffdddbf832a2779fc34e6bd00
2021-02-01 06:04:28 +00:00
Aravind K P
64d776c9de cli: fix cli migrations tests
https://github.com/hasura/graphql-engine-mono/pull/437

* cli: fix cli migrations tests

* dummy change to trigger tests

* update validation metadata files

* fix test files

* dummy code change

GitOrigin-RevId: e9ad86a80756e94b33df670885f8abb96f8f2e38
2021-01-29 17:41:25 +00:00
Swann Moreau
0b294bab5c update resource limits on circleci [force ci]
GitOrigin-RevId: 0ed0c7d32400f0a940be7ad1b22a6b55b751cbb5
2021-01-29 14:36:07 +00:00
Tirumarai Selvan A
88c3d7c787 tag release v1.4.0-alpha.1
GitOrigin-RevId: f09f265175226f96faba53ccfe68349377523f98
2021-01-29 12:31:13 +00:00
Vladimir Ciobanu
1bda14960e update pg-client-hs to revert buffer shrinking
GitOrigin-RevId: f8c47c2551c09a9e9f0d57a68c983f580d796c00
2021-01-29 12:04:39 +00:00
Karthikeyan Chinnakonda
10a3f9960d server: new function permissions layer
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 35645121242294cb6bb500ea598e9a1f2ca67fa1
2021-01-29 05:49:09 +00:00
Lyndon Maydwell
0767333597 server: support restified versions of graphql queries (#303)
Restified GraphQL Endpoints feature.

GitOrigin-RevId: 3d6e589426ec21a60a915b47f579f0ac4934af45
2021-01-29 01:03:35 +00:00
hasura-bot
66a3d8dab5 console: remote schema permissions
GITHUB_PR_NUMBER: 6156
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6156

Co-authored-by: Abhijeet Singh Khangarot <26903230+abhi40308@users.noreply.github.com>
Co-authored-by: Sooraj <8408875+soorajshankar@users.noreply.github.com>
GitOrigin-RevId: 3ddd61fc24bd1416e66a84579372b7a372dd4293
2021-01-28 15:59:34 +00:00
Rakesh Emmadi
ff3c58f230 ci: fix oss test server upgrade ci test when upgrading from 1.3.3
GitOrigin-RevId: a5b663ea5b079212c063f15bc67559f5a234f96f
2021-01-28 11:40:24 +00:00
hasura-bot
1fb92b85e6 console: add session argument input for computed fields (close #5154)
Co-authored-by: Sameer Kolhar <sameer@hasura.io>
Co-authored-by: Sameer Kolhar <kolhar730@gmail.com>
GITHUB_PR_NUMBER: 5610
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/5610

Co-authored-by: Sameer Kolhar <sameer@hasura.io>
Co-authored-by: Sameer Kolhar <kolhar730@gmail.com>
GitOrigin-RevId: 84d9d54ccf5ac375c3a6f2cd9dcbd8119e05bc29
2021-01-28 00:00:20 +00:00
hasura-bot
3cac1c30c0 console: show only compatible postgres functions in computed fields section (close #5155)
GITHUB_PR_NUMBER: 5978
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/5978

Co-authored-by: Dmitry Grachikov <696824+GrizliK1988@users.noreply.github.com>
Co-authored-by: Aleksandra Sikora <9019397+beerose@users.noreply.github.com>
GitOrigin-RevId: 9399fae17ab3985fa0dd0339b6a36f0ac57997fa
2021-01-26 18:12:59 +00:00
Antoine Leblanc
353859db09 server: remove GraphQL.Utils
GitOrigin-RevId: 90639f9f3d263ccb0ce4e3b8b6e19ce784f4b25d
2021-01-26 13:14:35 +00:00
Antoine Leblanc
62a3bb0d9e Move text operator out of SQL.Types. (#406)
GitOrigin-RevId: 25adad545b302fd1dde25ea0365d492dfcdaa71d
2021-01-26 12:23:20 +00:00