Skip to content

feat: Add Top-level logLevel propagated to every component - #487

Open
EkVid wants to merge 56 commits into
apache:mainfrom
EkVid:feat/log-level-sync-main
Open

EkVid wants to merge 56 commits into
apache:mainfrom
EkVid:feat/log-level-sync-main

Conversation

@EkVid

@EkVid EkVid commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

Adds a top-level spec.logLevel (debug, info, warning, error, critical, default to info) for the Superset application log level. It's inherited by the Python components and lifecycle tasks, with a per component logLevel on webServer, celeryWorker, celeryBeat, celeryFlower and mcpServer, and a single lifecycle.logLevel that override it. The operator maps the resolved level onto each component's own mechanism.

Part of #453

Details

Design notes

  • The rendered config is the same at every level, so a level change doesn't change ConfigHash or init's EnvHash, and lifecycle tasks aren't triggered again
  • The level isn't in the shared config checksum, so each component's level only reaches its own pod template
  • No Kubernetes default on any logLevel, info is applied at resolution

Mechanisms

  • LOG_LEVEL in every rendered superset_config.py, read from SUPERSET_OPERATOR__LOG_LEVEL
  • --loglevel for the Celery worker and Beat, including the fallback command used with preset: disabled
  • FLOWER_LOGGING for Flower, Celery and Flower both reset the root logger at startup, so they need the extra setting

Server process loggers keep their own native settings:

  • webServer.gunicorn.logLevel is unchanged from main and is independent of logLevel
  • The websocket server keeps websocketServer.config.logLevel, and no LOG_LEVEL is injected
  • No FASTMCP_LOG_LEVEL is set on the MCP server

DebugLogging condition

When any resolved level is debug and environment isn't Development, the Superset status gets a DebugLogging condition listing the affected components, and the operator emits one Warning Event when it first appears. The condition is removed when debug is turned off and doesn't affect Ready or Available. Only the typed field is checked, not a LOG_LEVEL set in config

Upgrade effects

There's no breaking change. These effects are in the release notes and docs:

  • Every rendered superset_config.py gains the LOG_LEVEL line, so upgrading the operator rolls every Python component once and runs init once
  • The Celery worker and Beat now log at info instead of Celery's warning default
  • FLASK_DEBUG=1 no longer implies debug logging, since the operator sets LOG_LEVEL itself

Tests and docs

  • Unit and envtest tests for resolution and component specific wiring, the websocket server ignoring logLevel, the checksum behaviors (rendered config, ConfigHash and init inputs unchanged), and the DebugLogging condition and Event
  • configuration.md: updated log level mapping table and reserved env var table, where to set the gunicorn and websocket levels, a "Debug Logging Outside Development" section, and the FLASK_DEBUG note
  • Release notes based on the changes

@codecov-commenter

codecov-commenter commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (c6acbdc) to head (830ba8f).
⚠️ Report is 4 commits behind head on main.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@villebro

villebro commented Nov 6, 2026

Copy link
Copy Markdown
Member

@EkVid is this ready for review?

@EkVid

EkVid commented Nov 6, 2026

Copy link
Copy Markdown
Author

@EkVid is this ready for review?

@villebro Thanks for checking, I am waiting for my teammates to finish the rest of the work. I will tag you once it's ready for review, thank you!

@villebro

Copy link
Copy Markdown
Member

FYI @EkVid : a recent PR #508 clarifies when to use enums vs loosely typed properties, and might impact how you want to implement log levels. I suspect this will be the exception to the rule, where we want to use enums as opposed to just pass-through strings, as we need to standardize these across components. Curious to hear your thoughts.

@EkVid

EkVid commented Nov 13, 2026 •

Copy link
Copy Markdown
Author

@villebro Thanks for the heads up! I agree, log level should be an enum. I went through #508, seems like its rule is to use an enum when the operator defines the allowed values and a plain string when it passes them unchanged to upstream. So log level should be using enum since the user can pick a value from the operator's allowed list, and the operator then translates it into what each component expects.

I also saw that #508 keeps webServer.gunicorn.logLevel, which I removed in this PR. I will probably do a rebase and keep the level removed. Thanks!

Resolve the overlap with apache#508 by keeping webServer.gunicorn.logLevel
removed: Gunicorn's level now comes from spec.logLevel /
webServer.logLevel. Drop the unused defaultLogLevel constant,
regenerate CRDs and API docs, and update the Gunicorn log level docs.
@EkVid
EkVid force-pushed the feat/log-level-sync-main branch from e8d076f to 744a6a9 Compare November 13, 2026 00:50
@EkVid

EkVid commented Nov 17, 2026

Copy link
Copy Markdown
Author

Hi @villebro, this PR should be ready for review now. I've added instructions for testing the behavior as an end user if you need them.

Setup

kind create cluster
kubectl apply -f config/samples/dev-dependencies.yaml
make install && make run

Keep make run running in its own terminal, then save the following as test.yaml and apply it:

apiVersion: superset.apache.org/v1alpha1
kind: Superset
metadata:
  name: my-superset
spec:
  image:
    tag: "6.1.0-dev"            # seems like 6.1.0 doesn't have psycopg2, so change to dev
  environment: Development
  secretKey: thisIsNotSecure_changeInProduction!
  metastore:
    host: postgres
    port: 5432
    database: superset
    username: superset
    password: superset
  valkey:
    host: valkey
    password: superset

  logLevel: info          # top level default for everything below

  webServer: {}
  celeryWorker: {}
  celeryBeat: {}
  mcpServer: {}
  celeryFlower:
    bootstrapScript: |
      uv pip install --no-cache flower
    podTemplate:
      podSecurityContext:           # flower isn't in the image, we need to install it at startup as root
        runAsNonRoot: false
        runAsUser: 0
  websocketServer:         # experimental feature, which needs its own image
    image:
      repository: oneacrefund/superset-websocket
      tag: "latest"
    config:
      logLevel: debug
      jwtSecret: CHANGE-ME-to-a-32-char-or-longer-secret
      redis: {host: valkey, port: 6379, password: superset}

  lifecycle: {}

Apply the configuration and monitor the Superset resource:

kubectl apply -f test.yaml
kubectl get superset my-superset -w

Wait for LIFECYCLE to show Complete before continuing.

Test Instructions

  1. Change a log level in test.yaml, either the top level logLevel or a component's own logLevel to override it.

  2. Apply the changes and wait for the new pods (5 seconds should be enough):

    kubectl apply -f test.yaml
    sleep 5
    kubectl get pods
  3. Important: Make sure to read logs only from pods whose AGE is a few seconds. Older pods may contain logs from the previous log level.

  4. Check the setting injected by the operator (the Injected setting column below), then inspect the logs.

For every component, a log level shows its own severity and everything more severe:

Log level Expected logs
debug DEBUG lines present
info (default) No DEBUG; INFO present
warning No DEBUG or INFO; WARNING present
error / critical No DEBUG, INFO, or WARNING

@EkVid
EkVid marked this pull request as ready for review November 17, 2026 16:02

@villebro villebro left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for marking this ready, it's coming along nicely. Before this can merge, the scope needs to change and a few pieces are still missing. The env-var approach for LOG_LEVEL is right: level changes stay out of ConfigHash and init's EnvHash.

Looking at this against the development guidelines, I've changed my mind on several answers I gave in #453, and I'm sorry for the back-and-forth, especially where you'd already implemented what I asked for. The reversals:

  • Q1: I said to remove webServer.gunicorn.logLevel. It should stay as on main.
  • Q3 (Gunicorn part): I said to inject GUNICORN_LOGLEVEL even with gunicorn.preset: disabled. It goes back under the preset, as on main.
  • Q5: I suggested setting FASTMCP_LOG_LEVEL on the MCP container. Leave it out of this PR.
  • Websocket: I asked you to inject LOG_LEVEL when a level is set explicitly. It shouldn't be injected at all.
  • Flower: I suggested mapping critical to error. Tornado accepts critical, so pass it through.

Thanks for your patience. Here's the full revised scope in one place:

logLevel is the Superset app level.

  • spec.logLevel, a per-component logLevel on the Python components (web server, Celery worker, Celery Beat, Flower, MCP server), and lifecycle.logLevel. Same scoping as sqlaEngineOptions.
  • It stays an enum, which fits the guideline: the operator defines the values and acts on them. It translates them per component and detects debug for the DebugLogging condition.
  • Mechanisms:
    • Rendered LOG_LEVEL everywhere.
    • --loglevel for the Celery worker and Beat.
    • FLOWER_LOGGING for Flower.
    • Celery and Flower need the extra setting for the same reason: both reset the root logger at startup, so the app and the tool share one logger.

Server-process loggers keep their own native settings. The guidelines say not to enum values passed through to software the operator doesn't control, and they name the Gunicorn log level as the example. They also say to keep a field per-component when its meaning is specific to one component.

  • Gunicorn: revising Q1. Keep webServer.gunicorn.logLevel exactly as on main: a pass-through *string with an info default, independent of logLevel. Gunicorn's --log-level only affects the gunicorn.error logger, not the app. That also revises Q3 for Gunicorn: GUNICORN_LOGLEVEL goes back under the tuning preset, as on main. Celery's fallback command still gets --loglevel, as agreed.
  • Websocket: it doesn't read superset_config.py and already has a native websocketServer.config.logLevel. It ignores the top-level value, the way Beat ignores autoscaling. No LOG_LEVEL injection and no Winston translation, which replaces my earlier "inject only when explicit" answer.
  • MCP: same idea for FastMCP/Uvicorn. Leave FASTMCP_LOG_LEVEL out of this PR. It can become a per-component pass-through later if there's demand.

What this simplifies:

  • No breaking change, so no **Breaking:** release note.
  • The precedence question between the websocket env and its config goes away.
  • Less translation code.
  • A Gunicorn level change still restarts every component via the shared checksum, as on main. That's the separate issue from Q2.

Still needed before merge, in order of importance. These are the items from the PR description (the list lost its "Not in this draft yet" heading but still applies), plus a few from this review:

  • Tests that a level change keeps the rendered config, ConfigHash and init's EnvHash unchanged, and only rolls the affected component's pods. The design depends on this, so it's the most important missing piece.
  • The DebugLogging condition + a Warning Event emitted once, covering only the app level, and docs/release note. The release note should mention that the Celery worker and Beat now log at INFO instead of Celery's WARNING.
  • Docs: update the mapping table and reserved env var table in configuration.md. That means removing the websocket LOG_LEVEL row, describing gunicorn.logLevel as separate from logLevel, and adding a sentence on where to set the Gunicorn and websocket levels.
  • Please confirm FLOWER_LOGGING on a running Flower pod. The branch history has it removed as unconfirmed and then added back.
  • Since this PR now renders LOG_LEVEL itself, FLASK_DEBUG=1 no longer implies debug logging (upstream sets LOG_LEVEL = DEBUG if DEBUG else INFO). A one-line note in the docs is enough.

Comment thread api/v1alpha1/shared_types.go Resolved
Comment thread api/v1alpha1/shared_types.go Resolved
Comment thread internal/controller/loglevel.go Resolved
Comment thread internal/config/loglevel.go Resolved
Comment thread internal/config/loglevel.go Resolved
@EkVid

EkVid commented Nov 21, 2026 •

Copy link
Copy Markdown
Author

Hi @villebro, I have made the necessary changes based on the comments. It would be great if you can review it again whenever you have time.

I confirmed that FLOWER_LOGGING is working on a pod. I copied the method I used for reference:

(Assumes the pod is already running, and change the logLevel to info, debug, and critical)

kubectl get superset {superset_name} -o jsonpath='{.spec.celeryFlower.logLevel}'

kubectl exec {pod_name} -c superset -- printenv FLOWER_LOGGING
=> INFO/DEBUG/CRITICAL

$ kubectl logs {pod_name} -c superset | grep -oE ':(DEBUG|INFO|WARNING|ERROR|CRITICAL):[a-z_.]+' | sort | uniq -c | sort -rn
=> uniques lines grouped by INFO, DEBUG, or CRITICAL

In addition, the debugLogging is tested and working as expected, the method is below:

# Mock Staging Superset with debug that uses secretKeyFrom
kubectl create secret generic superset-secret --from-literal=secret-key="$(openssl rand -base64 42)"
kubectl apply -f - <<'EOF'
apiVersion: superset.apache.org/v1alpha1
kind: Superset
metadata:
  name: superset-staging
spec:
  environment: Staging
  image:
    tag: 6.1.0-dev
  secretKeyFrom:
    name: superset-secret
    key: secret-key
  logLevel: debug
  webServer: {}
  celeryBeat: {}
  lifecycle:
    disabled: true
EOF

# Condition is True, listing webserver and celery beat, and one Warning Event is emitted
kubectl get superset superset-staging -o jsonpath='{.status.conditions[?(@.type=="DebugLogging")]}'
kubectl describe superset superset-staging | sed -n '/^Events:/,$p'

# Check another reconcile doesn't repeat the event
kubectl annotate superset superset-staging test/poke="$(date +%s)" --overwrite
kubectl describe superset superset-staging | sed -n '/^Events:/,$p'

# A component override updates the message to just webserver
kubectl patch superset superset-staging --type merge -p '{"spec":{"celeryBeat":{"logLevel":"info"}}}'
kubectl get superset superset-staging -o jsonpath='{.status.conditions[?(@.type=="DebugLogging")].message}'

# Turning debug off removes the condition
kubectl patch superset superset-staging --type merge -p '{"spec":{"logLevel":"info"}}'
kubectl get superset superset-staging -o jsonpath='{.status.conditions[*].type}'

# The Control that has no condition in DEV
kubectl patch superset superset-dev --type merge -p '{"spec":{"logLevel":"debug"}}'
kubectl get superset superset-dev -o jsonpath='{.status.conditions[?(@.type=="DebugLogging")]}'

Please let me know if you want me to share more details of the testing, and thank you so much for your time!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants