apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.22k stars 13.33k forks source link

Custom chart plugins not working in Kubernetes deployment #29588

Closed mayanklalwani closed 1 month ago

mayanklalwani commented 1 month ago

Bug description

I made a custom chart plugin and tested it locally (through docker-compose deployment) and the chart was working fine. I tried deploying the same docker image on Kubernetes cluster where my application is working, I can see the new plugin code is there at the desired location after this but the chart doesn't appear on the UI.

How to reproduce the bug

1.) Create a new chart plugin. 2.) Deploy on Superset running through Kubernetes. 3.) After successful deployment, check if the new chart appears on UI.

Screenshots/recordings

No response

Superset version

3.1.3

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

dosubot[bot] commented 1 month ago

The issue might be related to the dynamic imports (lazy-loading) of your custom chart plugin components. When deploying on a Kubernetes cluster, the environment might not be correctly resolving these dynamic imports, which can cause the plugin not to appear on the UI.

In the ChartPlugin class, the sanitizeLoader function is used to handle dynamic imports. Ensure that your Kubernetes environment has the necessary configurations to support these dynamic imports.

Here is a snippet from the ChartPlugin class that deals with dynamic imports:

function sanitizeLoader<T extends object>(
  loader: PromiseOrValueLoader<ValueOrModuleWithValue<T>>,
): PromiseOrValueLoader<T> {
  return () => {
    const loaded = loader();

    return loaded instanceof Promise
      ? (loaded.then(
          module => ('default' in module && module.default) || module,
        ) as Promise<T>)
      : (loaded as T);
  };
}

Make sure that your Kubernetes deployment is set up to handle these dynamic imports correctly. This might involve ensuring that the necessary files are available and correctly referenced in your deployment configuration [1].

Additionally, you need to enable the DYNAMIC_PLUGINS feature flag in the superset_config.py file. This can be done by specifying key/value entries in configOverrides in your values.yaml file:

configOverrides:
  my_override: |
    FEATURE_FLAGS = {
        "DYNAMIC_PLUGINS": True
    }

This configuration will ensure that the DYNAMIC_PLUGINS feature is enabled, allowing you to deploy custom chart plugins in Apache Superset [2][3].

To continue talking to Dosu, mention @dosu.

mayanklalwani commented 1 month ago

Yes, these settings are there in my environment