From 175bbd47bcc02629f9db098dcb06d92452a19455 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Fri, 22 Dec 2023 11:20:39 -0300 Subject: [PATCH 1/2] refactor: Removes the CLIENT_CACHE feature flag --- RESOURCES/FEATURE_FLAGS.md | 1 - UPDATING.md | 2 + .../installation/configuring-superset.mdx | 34 ++++++------ .../src/utils/featureFlags.ts | 1 - .../test/utils/featureFlag.test.ts | 7 +-- .../src/components/Chart/Chart.jsx | 30 +++------- .../src/components/Chart/chartAction.js | 55 +------------------ superset/config.py | 1 - 8 files changed, 33 insertions(+), 98 deletions(-) diff --git a/RESOURCES/FEATURE_FLAGS.md b/RESOURCES/FEATURE_FLAGS.md index d029ca6c3cbd6..2349b3e100896 100644 --- a/RESOURCES/FEATURE_FLAGS.md +++ b/RESOURCES/FEATURE_FLAGS.md @@ -86,7 +86,6 @@ These features flags currently default to True and **will be removed in a future [//]: # "PLEASE KEEP THE LIST SORTED ALPHABETICALLY" -- CLIENT_CACHE - DASHBOARD_CACHE - DASHBOARD_FILTERS_EXPERIMENTAL - DASHBOARD_NATIVE_FILTERS diff --git a/UPDATING.md b/UPDATING.md index b5c48924b727e..f8b0e0b601ff2 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -29,6 +29,8 @@ assists people when migrating to a new version. ### Breaking Changes +- [26348](https://github.com/apache/superset/issues/26348): Removes the deprecated `CLIENT_CACHE` feature flag. + ### Potential Downtime ### Other diff --git a/docs/docs/installation/configuring-superset.mdx b/docs/docs/installation/configuring-superset.mdx index 155f82e07a94e..820feaeec9434 100644 --- a/docs/docs/installation/configuring-superset.mdx +++ b/docs/docs/installation/configuring-superset.mdx @@ -9,24 +9,27 @@ version: 1 ### Configuration -To configure your application, you need to create a file `superset_config.py`. Add this file to your +To configure your application, you need to create a file `superset_config.py`. Add this file to your `PYTHONPATH` or create an environment variable `SUPERSET_CONFIG_PATH` specifying the full path of the `superset_config.py`. For example, if deploying on Superset directly on a Linux-based system where your `superset_config.py` is under `/app` directory, you can run: + ```bash export SUPERSET_CONFIG_PATH=/app/superset_config.py ``` If you are using your own custom Dockerfile with official Superset image as base image, then you can add your overrides as shown below: + ```bash COPY --chown=superset superset_config.py /app/ ENV SUPERSET_CONFIG_PATH /app/superset_config.py ``` -Docker compose deployments handle application configuration differently. See [https://github.com/apache/superset/tree/master/docker#readme](https://github.com/apache/superset/tree/master/docker#readme) for details. +Docker compose deployments handle application configuration differently. See [https://github.com/apache/superset/tree/master/docker#readme](https://github.com/apache/superset/tree/master/docker#readme) for details. The following is an example of just a few of the parameters you can set in your `superset_config.py` file: + ``` # Superset specific config ROW_LIMIT = 5000 @@ -88,7 +91,7 @@ WTF_CSRF_EXEMPT_LIST = [‘’] #### Adding an initial SECRET_KEY -Superset requires a user-specified SECRET_KEY to start up. This requirement was [added in version 2.1.0 to force secure configurations](https://preset.io/blog/superset-security-update-default-secret_key-vulnerability/). Add a strong SECRET_KEY to your `superset_config.py` file like: +Superset requires a user-specified SECRET_KEY to start up. This requirement was [added in version 2.1.0 to force secure configurations](https://preset.io/blog/superset-security-update-default-secret_key-vulnerability/). Add a strong SECRET_KEY to your `superset_config.py` file like: ```python SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY' @@ -99,7 +102,7 @@ You can generate a strong secure key with `openssl rand -base64 42`. #### Rotating to a newer SECRET_KEY If you wish to change your existing SECRET_KEY, add the existing SECRET_KEY to your `superset_config.py` file as -`PREVIOUS_SECRET_KEY = `and provide your new key as `SECRET_KEY =`. You can find your current SECRET_KEY with these +`PREVIOUS_SECRET_KEY = `and provide your new key as `SECRET_KEY =`. You can find your current SECRET_KEY with these commands - if running Superset with Docker, execute from within the Superset application container: ```python @@ -119,23 +122,21 @@ database engine on a separate host or container. Superset supports the following database engines/versions: -| Database Engine | Supported Versions | -| --------------------------------------------------------- | ---------------------------------- | -| [PostgreSQL](https://www.postgresql.org/) | 10.X, 11.X, 12.X, 13.X, 14.X, 15.X | -| [MySQL](https://www.mysql.com/) | 5.7, 8.X | - +| Database Engine | Supported Versions | +| ----------------------------------------- | ---------------------------------- | +| [PostgreSQL](https://www.postgresql.org/) | 10.X, 11.X, 12.X, 13.X, 14.X, 15.X | +| [MySQL](https://www.mysql.com/) | 5.7, 8.X | Use the following database drivers and connection strings: -| Database | PyPI package | Connection String | -| ----------------------------------------- | --------------------------------- | ------------------------------------------------------------------------ | -| [PostgreSQL](https://www.postgresql.org/) | `pip install psycopg2` | `postgresql://:@/` | -| [MySQL](https://www.mysql.com/) | `pip install mysqlclient` | `mysql://:@/` | +| Database | PyPI package | Connection String | +| ----------------------------------------- | ------------------------- | ---------------------------------------------------------------------- | +| [PostgreSQL](https://www.postgresql.org/) | `pip install psycopg2` | `postgresql://:@/` | +| [MySQL](https://www.mysql.com/) | `pip install mysqlclient` | `mysql://:@/` | To configure Superset metastore set `SQLALCHEMY_DATABASE_URI` config key on `superset_config` to the appropriate connection string. - ### Running on a WSGI HTTP Server While you can run Superset on NGINX or Apache, we recommend using Gunicorn in async mode. This @@ -167,7 +168,7 @@ So, when you use `BigQuery` datasource on Superset, you have to use `gunicorn` w ### HTTPS Configuration -You can configure HTTPS upstream via a load balancer or a reverse proxy (such as nginx) and do SSL/TLS Offloading before traffic reaches the Superset application. In this setup, local traffic from a Celery worker taking a snapshot of a chart for Alerts & Reports can access Superset at a `http://` URL, from behind the ingress point. +You can configure HTTPS upstream via a load balancer or a reverse proxy (such as nginx) and do SSL/TLS Offloading before traffic reaches the Superset application. In this setup, local traffic from a Celery worker taking a snapshot of a chart for Alerts & Reports can access Superset at a `http://` URL, from behind the ingress point. You can also configure [SSL in Gunicorn](https://docs.gunicorn.org/en/stable/settings.html#ssl) (the Python webserver) if you are using an official Superset Docker image. ### Configuration Behind a Load Balancer @@ -191,7 +192,7 @@ RequestHeader set X-Forwarded-Proto "https" ### Custom OAuth2 Configuration Superset is built on Flask-AppBuilder (FAB), which supports many providers out of the box -(GitHub, Twitter, LinkedIn, Google, Azure, etc). Beyond those, Superset can be configured to connect +(GitHub, Twitter, LinkedIn, Google, Azure, etc). Beyond those, Superset can be configured to connect with other OAuth2 Authorization Server implementations that support “code” authorization. Make sure the pip package [`Authlib`](https://authlib.org/) is installed on the webserver. @@ -357,7 +358,6 @@ You can enable or disable features with flag from `superset_config.py`: ```python FEATURE_FLAGS = { - 'CLIENT_CACHE': False, 'ENABLE_EXPLORE_JSON_CSRF_PROTECTION': False, 'PRESTO_EXPAND_DATA': False, } diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index 6bc77e0e87a1a..d7ba3800d9e41 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -25,7 +25,6 @@ export enum FeatureFlag { ALERTS_ATTACH_REPORTS = 'ALERTS_ATTACH_REPORTS', ALERT_REPORTS = 'ALERT_REPORTS', ALLOW_FULL_CSV_EXPORT = 'ALLOW_FULL_CSV_EXPORT', - CLIENT_CACHE = 'CLIENT_CACHE', DASHBOARD_CROSS_FILTERS = 'DASHBOARD_CROSS_FILTERS', DASHBOARD_FILTERS_EXPERIMENTAL = 'DASHBOARD_FILTERS_EXPERIMENTAL', CONFIRM_DASHBOARD_DIFF = 'CONFIRM_DASHBOARD_DIFF', diff --git a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts index 8c6a45ef0c479..bad77690a4dcf 100644 --- a/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/utils/featureFlag.test.ts @@ -31,7 +31,6 @@ it('initializes feature flags with predefined values', () => { value: undefined, }); const featureFlags = { - CLIENT_CACHE: true, DRILL_BY: false, }; uiCore.initFeatureFlags(featureFlags); @@ -67,10 +66,8 @@ it('returns false for unset feature flag', () => { it('returns true for set feature flag', () => { Object.defineProperty(window, 'featureFlags', { value: { - CLIENT_CACHE: true, + DRILL_BY: true, }, }); - expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.CLIENT_CACHE)).toEqual( - true, - ); + expect(uiCore.isFeatureEnabled(uiCore.FeatureFlag.DRILL_BY)).toEqual(true); }); diff --git a/superset-frontend/src/components/Chart/Chart.jsx b/superset-frontend/src/components/Chart/Chart.jsx index da9a81516f5e8..401fa52f2798d 100644 --- a/superset-frontend/src/components/Chart/Chart.jsx +++ b/superset-frontend/src/components/Chart/Chart.jsx @@ -155,27 +155,15 @@ class Chart extends React.PureComponent { } runQuery() { - if (this.props.chartId > 0 && isFeatureEnabled(FeatureFlag.CLIENT_CACHE)) { - // Load saved chart with a GET request - this.props.actions.getSavedChart( - this.props.formData, - this.props.force || getUrlParam(URL_PARAMS.force), // allow override via url params force=true - this.props.timeout, - this.props.chartId, - this.props.dashboardId, - this.props.ownState, - ); - } else { - // Create chart with POST request - this.props.actions.postChartFormData( - this.props.formData, - Boolean(this.props.force || getUrlParam(URL_PARAMS.force)), // allow override via url params force=true - this.props.timeout, - this.props.chartId, - this.props.dashboardId, - this.props.ownState, - ); - } + // Create chart with POST request + this.props.actions.postChartFormData( + this.props.formData, + Boolean(this.props.force || getUrlParam(URL_PARAMS.force)), // allow override via url params force=true + this.props.timeout, + this.props.chartId, + this.props.dashboardId, + this.props.ownState, + ); } handleRenderContainerFailure(error, info) { diff --git a/superset-frontend/src/components/Chart/chartAction.js b/superset-frontend/src/components/Chart/chartAction.js index 8cd3785ae5156..fbb790824cdc7 100644 --- a/superset-frontend/src/components/Chart/chartAction.js +++ b/superset-frontend/src/components/Chart/chartAction.js @@ -143,11 +143,7 @@ const legacyChartDataRequest = async ( parseMethod, }; - const clientMethod = - 'GET' && isFeatureEnabled(FeatureFlag.CLIENT_CACHE) - ? SupersetClient.get - : SupersetClient.post; - return clientMethod(querySettings).then(({ json, response }) => + return SupersetClient.post(querySettings).then(({ json, response }) => // Make the legacy endpoint return a payload that corresponds to the // V1 chart data endpoint response signature. ({ @@ -379,7 +375,6 @@ export function exploreJSON( force = false, timeout = 60, key, - method, dashboardId, ownState, ) { @@ -402,7 +397,7 @@ export function exploreJSON( resultFormat: 'json', resultType: 'full', force, - method, + method: 'POST', requestParams, ownState, }); @@ -518,36 +513,6 @@ export function exploreJSON( }; } -export const GET_SAVED_CHART = 'GET_SAVED_CHART'; -export function getSavedChart( - formData, - force = false, - timeout = 60, - key, - dashboardId, - ownState, -) { - /* - * Perform a GET request to `/explore_json`. - * - * This will return the payload of a saved chart, optionally filtered by - * ad-hoc or extra filters from dashboards. Eg: - * - * GET /explore_json?{"chart_id":1} - * GET /explore_json?{"chart_id":1,"extra_filters":"..."} - * - */ - return exploreJSON( - formData, - force, - timeout, - key, - 'GET', - dashboardId, - ownState, - ); -} - export const POST_CHART_FORM_DATA = 'POST_CHART_FORM_DATA'; export function postChartFormData( formData, @@ -557,21 +522,7 @@ export function postChartFormData( dashboardId, ownState, ) { - /* - * Perform a POST request to `/explore_json`. - * - * This will post the form data to the endpoint, returning a new chart. - * - */ - return exploreJSON( - formData, - force, - timeout, - key, - 'POST', - dashboardId, - ownState, - ); + return exploreJSON(formData, force, timeout, key, dashboardId, ownState); } export function redirectSQLLab(formData, history) { diff --git a/superset/config.py b/superset/config.py index 348baef5454af..d6f3066b073a9 100644 --- a/superset/config.py +++ b/superset/config.py @@ -403,7 +403,6 @@ class D3Format(TypedDict, total=False): # will result in combined feature flags of { 'FOO': True, 'BAR': True, 'BAZ': True } DEFAULT_FEATURE_FLAGS: dict[str, bool] = { # Experimental feature introducing a client (browser) cache - "CLIENT_CACHE": False, # deprecated "DISABLE_DATASET_SOURCE_EDIT": False, # deprecated # When using a recent version of Druid that supports JOINs turn this on "DRUID_JOINS": False, From a2b12206641b1f928f20928397a785aa842b39f5 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:40:31 -0300 Subject: [PATCH 2/2] Update UPDATING.md --- UPDATING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPDATING.md b/UPDATING.md index f8b0e0b601ff2..f38be8187f53c 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -29,7 +29,7 @@ assists people when migrating to a new version. ### Breaking Changes -- [26348](https://github.com/apache/superset/issues/26348): Removes the deprecated `CLIENT_CACHE` feature flag. +- [26348](https://github.com/apache/superset/issues/26348): Removes the deprecated `CLIENT_CACHE` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed. ### Potential Downtime