You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2026/10/15 03:42:15 UTC

(superset-kubernetes-operator) branch main updated: fix(config): render Valkey SSL options without cert files (#440)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/superset-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new fbc3e81  fix(config): render Valkey SSL options without cert files (#440)
fbc3e81 is described below

commit fbc3e81f79533111910564aa5b240722ff91311a
Author: Younsung Lee <cy...@kakao.com>
AuthorDate: Thu Oct 15 12:42:10 2026 +0900

    fix(config): render Valkey SSL options without cert files (#440)
    
    * fix(config): render Valkey SSL options without certificate files
    
    When spec.valkey.ssl was set without keyFile, certFile, or caCertFile
    (for example ssl: {} for a server that only needs an encrypted
    connection, like ElastiCache with in-transit encryption), the operator
    did not render the shared SSL options. CeleryConfig then had rediss://
    URLs but no broker_use_ssl or redis_backend_use_ssl, and the Celery
    result backend refuses to start in that case:
    
      ValueError: A rediss:// URL must have parameter ssl_cert_reqs and
      this must be set to CERT_REQUIRED, CERT_OPTIONAL, or CERT_NONE
    
    Because of the same check, ssl.certRequired was silently ignored unless
    a certificate path was also set.
    
    Now the SSL options, including ssl_cert_reqs, are rendered whenever SSL
    is enabled. Certificate paths are still added only when they are set.
    Flask-Caching and the results backend already used required
    verification by default, so their behavior only changes when
    certRequired is set to a different value. Existing Deployments that
    use SSL roll once because the rendered config changes.
    
    Signed-off-by: younsl <cy...@kakao.com>
    
    * docs(releases): add changelog entry for Valkey SSL fix
    
    Add a Fixed entry under Unreleased that explains the Celery worker crash
    loop with ssl: {} and the one-time rollout for Deployments that use SSL.
    
    Signed-off-by: younsl <cy...@kakao.com>
    
    ---------
    
    Signed-off-by: younsl <cy...@kakao.com>
---
 docs/reference/releases.md       |  1 +
 internal/config/celery_app.go    |  4 ++--
 internal/config/renderer.go      |  9 +++------
 internal/config/renderer_test.go | 39 ++++++++++++++++++++++++++++++++++-----
 4 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/docs/reference/releases.md b/docs/reference/releases.md
index 341925a..a727ae1 100644
--- a/docs/reference/releases.md
+++ b/docs/reference/releases.md
@@ -38,6 +38,7 @@ This page tracks notable changes in Apache Superset Kubernetes Operator releases
 ### Fixed
 
 - Credential redaction in lifecycle task failure messages now masks the whole value when a quoted credential key is followed by empty quotes and more characters, such as `{"password": ""hunter2}`. Previously the characters after the empty quotes were left in the parent Superset status and Kubernetes Events ([#437](https://github.com/apache/superset-kubernetes-operator/pull/437), [@younsl](https://github.com/younsl)).
+- Setting `spec.valkey.ssl` without certificate files (for example `ssl: {}` for managed Valkey or Redis with in-transit encryption) no longer crash-loops the Celery worker. The operator now renders `ssl_cert_reqs` and the Celery `broker_use_ssl` and `redis_backend_use_ssl` options whenever SSL is enabled, and `ssl.certRequired` takes effect without certificate paths. Deployments that use SSL roll once on upgrade ([#440](https://github.com/apache/superset-kubernetes-operator/pull/440), [ [...]
 
 ## 0.3.0 - 2026-09-30
 
diff --git a/internal/config/celery_app.go b/internal/config/celery_app.go
index 82e4aba..2a62638 100644
--- a/internal/config/celery_app.go
+++ b/internal/config/celery_app.go
@@ -26,7 +26,7 @@ import (
 // renderCeleryClass writes only the CeleryConfig fields derived from structured
 // Valkey settings. Application-level Celery behavior such as imports, task
 // annotations, and beat schedules belongs in spec.config.
-func renderCeleryClass(b *strings.Builder, v *ValkeyInput, hasSSLOpts bool) {
+func renderCeleryClass(b *strings.Builder, v *ValkeyInput) {
 	brokerEnabled := !v.CeleryBroker.Disabled
 	resultEnabled := !v.CeleryResultBackend.Disabled
 	if !brokerEnabled && !resultEnabled {
@@ -41,7 +41,7 @@ func renderCeleryClass(b *strings.Builder, v *ValkeyInput, hasSSLOpts bool) {
 	if resultEnabled {
 		fmt.Fprintf(b, "    result_backend = f\"{_vk_base}/%d\"\n", v.CeleryResultBackend.Database)
 	}
-	if hasSSLOpts {
+	if v.SSL {
 		if brokerEnabled {
 			b.WriteString("    broker_use_ssl = _vk_ssl_opts\n")
 		}
diff --git a/internal/config/renderer.go b/internal/config/renderer.go
index 6660f0d..3aec0e9 100644
--- a/internal/config/renderer.go
+++ b/internal/config/renderer.go
@@ -261,8 +261,7 @@ func renderValkey(b *strings.Builder, v *ValkeyInput) {
 	fmt.Fprintf(b, "_superset_instance = os.environ['%s']\n", common.EnvInstanceName)
 
 	// SSL options dict (used by Flask-Caching CACHE_OPTIONS, CacheLib kwargs, and Celery).
-	hasSSLOpts := v.SSL && (v.SSLKeyFile != "" || v.SSLCertFile != "" || v.SSLCACertFile != "")
-	if hasSSLOpts {
+	if v.SSL {
 		certReq := v.SSLCertRequired
 		if certReq == "" {
 			certReq = "required"
@@ -305,14 +304,14 @@ func renderValkey(b *strings.Builder, v *ValkeyInput) {
 		fmt.Fprintf(b, "    \"CACHE_DEFAULT_TIMEOUT\": %d,\n", s.input.DefaultTimeout)
 		fmt.Fprintf(b, "    \"CACHE_KEY_PREFIX\": f\"{_superset_instance}_\" + \"%s\",\n", pyQuote(s.input.KeyPrefix))
 		fmt.Fprintf(b, "    \"CACHE_REDIS_URL\": f\"{_vk_base}/%d\",\n", s.input.Database)
-		if hasSSLOpts {
+		if v.SSL {
 			b.WriteString("    \"CACHE_OPTIONS\": _vk_ssl_opts,\n")
 		}
 		b.WriteString("}\n")
 	}
 
 	// Celery config.
-	renderCeleryClass(b, v, hasSSLOpts)
+	renderCeleryClass(b, v)
 
 	// Results backend (CacheLib RedisCache).
 	if !v.ResultsBackend.Disabled {
@@ -325,8 +324,6 @@ func renderValkey(b *strings.Builder, v *ValkeyInput) {
 		fmt.Fprintf(b, "    key_prefix=f\"{_superset_instance}_\" + \"%s\",\n", pyQuote(v.ResultsBackend.KeyPrefix))
 		if v.SSL {
 			b.WriteString("    ssl=True,\n")
-		}
-		if hasSSLOpts {
 			b.WriteString("    **_vk_ssl_opts,\n")
 		}
 		b.WriteString(")\n")
diff --git a/internal/config/renderer_test.go b/internal/config/renderer_test.go
index 8d158a6..469a1e4 100644
--- a/internal/config/renderer_test.go
+++ b/internal/config/renderer_test.go
@@ -265,8 +265,8 @@ func TestRenderConfig_ValkeyWithSSL(t *testing.T) {
 		Valkey: &ValkeyInput{
 			SSL:                  true,
 			Cache:                ValkeyCacheInput{Database: 1, KeyPrefix: "s_", DefaultTimeout: 300},
-			CeleryBroker:         ValkeyCeleryInput{Disabled: true},
-			CeleryResultBackend:  ValkeyCeleryInput{Disabled: true},
+			CeleryBroker:         ValkeyCeleryInput{Database: 0},
+			CeleryResultBackend:  ValkeyCeleryInput{Database: 0},
 			ResultsBackend:       ValkeyResultsInput{Database: 6, KeyPrefix: "r_"},
 			DataCache:            ValkeyCacheInput{Disabled: true},
 			FilterStateCache:     ValkeyCacheInput{Disabled: true},
@@ -277,10 +277,39 @@ func TestRenderConfig_ValkeyWithSSL(t *testing.T) {
 	result := RenderConfig(ComponentCeleryWorker, input)
 
 	assertContains(t, result, "_vk_scheme = \"rediss\"")
-	assertContains(t, result, "CACHE_CONFIG = {")
+	assertContains(t, result, "_vk_ssl_opts = {")
+	assertContains(t, result, "\"ssl_cert_reqs\": \"required\"")
+	assertNotContains(t, result, "ssl_keyfile")
+	assertNotContains(t, result, "ssl_certfile")
+	assertNotContains(t, result, "ssl_ca_certs")
+	assertContains(t, result, "\"CACHE_OPTIONS\": _vk_ssl_opts")
+	// Celery's rediss:// result backend refuses to start without ssl_cert_reqs.
+	assertContains(t, result, "broker_use_ssl = _vk_ssl_opts")
+	assertContains(t, result, "redis_backend_use_ssl = _vk_ssl_opts")
 	assertContains(t, result, "ssl=True")
-	// No ssl_opts when no cert paths set
-	assertNotContains(t, result, "_vk_ssl_opts")
+	assertContains(t, result, "**_vk_ssl_opts")
+}
+
+func TestRenderConfig_ValkeyWithSSLCertRequiredNone(t *testing.T) {
+	input := &ConfigInput{
+		Valkey: &ValkeyInput{
+			SSL:                  true,
+			SSLCertRequired:      "none",
+			Cache:                ValkeyCacheInput{Disabled: true},
+			DataCache:            ValkeyCacheInput{Disabled: true},
+			FilterStateCache:     ValkeyCacheInput{Disabled: true},
+			ExploreFormDataCache: ValkeyCacheInput{Disabled: true},
+			ThumbnailCache:       ValkeyCacheInput{Disabled: true},
+			CeleryBroker:         ValkeyCeleryInput{Database: 0},
+			CeleryResultBackend:  ValkeyCeleryInput{Database: 0},
+			ResultsBackend:       ValkeyResultsInput{Disabled: true},
+		},
+	}
+	result := RenderConfig(ComponentCeleryWorker, input)
+
+	assertContains(t, result, "\"ssl_cert_reqs\": \"none\"")
+	assertContains(t, result, "broker_use_ssl = _vk_ssl_opts")
+	assertContains(t, result, "redis_backend_use_ssl = _vk_ssl_opts")
 }
 
 func TestRenderConfig_ValkeyWithMTLS(t *testing.T) {