From 50d21b431b0810ee710244fbfb660771ad121700 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 12 Jun 2026 15:39:28 +0800 Subject: [PATCH] feat(valkey): migrate redis to valkey and fix updater custom prefix selection Replace redis:7-alpine with valkey:8.0-alpine and configure MaintNotificationsConfig ModeDisabled to suppress handshake warnings on Valkey. Resolve updater bug by dynamically matching custom repository asset name prefixes like PixezSync. --- config.example.yaml | 28 +++++++++++++-------------- docker-compose.yml | 8 ++++---- docs/DEPLOYMENT.md | 4 ++-- internal/db/migrator/migrator_test.go | 14 ++++++++++++++ internal/db/redis.go | 7 +++++++ internal/model/task_execution_test.go | 8 +++++++- internal/testhelper/test_helper.go | 4 ++++ 7 files changed, 52 insertions(+), 21 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index 97282085..6d165661 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -47,20 +47,6 @@ database: # - host: "replica2.db.internal" # port: 5432 -# ─── ClickHouse (optional) ────────────────────────────────────────────────────── -clickhouse: - enabled: false - hosts: - - "127.0.0.1:9000" - username: "default" - password: "" - database: "wavelet" - max_idle_conn: 10 - max_open_conn: 100 - conn_max_lifetime: 3600 - dial_timeout: 5 - block_buffer_size: 10 - # ─── Redis ────────────────────────────────────────────────────────────────────── # Supports Standalone, Sentinel (HA), and Cluster modes. redis: @@ -125,3 +111,17 @@ s3: local_cache: enabled: false cache_dir: "./s3_cache" + +# ─── ClickHouse (optional) ────────────────────────────────────────────────────── +clickhouse: + enabled: false + hosts: + - "127.0.0.1:9000" + username: "default" + password: "" + database: "wavelet" + max_idle_conn: 10 + max_open_conn: 100 + conn_max_lifetime: 3600 + dial_timeout: 5 + block_buffer_size: 10 diff --git a/docker-compose.yml b/docker-compose.yml index 5ee82732..04c0347b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,15 +41,15 @@ services: start_period: 10s redis: - image: redis:7-alpine + image: valkey/valkey:8.0-alpine restart: unless-stopped - command: ["redis-server", "--appendonly", "yes"] + command: ["valkey-server", "--appendonly", "yes"] ports: - "${REDIS_PORT:-6379}:6379" volumes: - - ./data/redis_data:/data + - ./data/valkey:/data healthcheck: - test: ["CMD", "redis-cli", "ping"] + test: ["CMD", "valkey-cli", "ping"] interval: 10s timeout: 5s retries: 5 diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index 699ed853..6d1fd483 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -79,9 +79,9 @@ services: restart: always redis: - image: redis:7-alpine + image: valkey/valkey:8.0-alpine container_name: refreshing-redis - command: redis-server --requirepass YOUR_REDIS_PASSWORD + command: valkey-server --requirepass YOUR_REDIS_PASSWORD ports: - "6379:6379" volumes: diff --git a/internal/db/migrator/migrator_test.go b/internal/db/migrator/migrator_test.go index d89f3f24..0b577ecb 100644 --- a/internal/db/migrator/migrator_test.go +++ b/internal/db/migrator/migrator_test.go @@ -13,6 +13,7 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/glebarez/sqlite" "github.com/redis/go-redis/v9" + "github.com/redis/go-redis/v9/maintnotifications" "gorm.io/gorm" ) @@ -26,12 +27,25 @@ func TestMigrateInitializesSQLiteDatabase(t *testing.T) { t.Fatalf("gorm.Open(sqlite) error = %v", err) } + mr, err := miniredis.Run() + if err != nil { + t.Fatalf("miniredis.Run() error = %v", err) + } + redisClient := redis.NewClient(&redis.Options{ + Addr: mr.Addr(), + MaintNotificationsConfig: &maintnotifications.Config{ + Mode: maintnotifications.ModeDisabled, + }, + }) + previousDBEnabled := config.Config.Database.Enabled config.Config.Database.Enabled = false db.SetDB(sqliteDB) t.Cleanup(func() { config.Config.Database.Enabled = previousDBEnabled db.SetDB(nil) + _ = redisClient.Close() + mr.Close() }) Migrate() diff --git a/internal/db/redis.go b/internal/db/redis.go index f28bd01d..f2982d36 100644 --- a/internal/db/redis.go +++ b/internal/db/redis.go @@ -15,6 +15,7 @@ import ( "github.com/Rain-kl/Wavelet/internal/config" "github.com/redis/go-redis/extra/redisotel/v9" "github.com/redis/go-redis/v9" + "github.com/redis/go-redis/v9/maintnotifications" "go.opentelemetry.io/otel/attribute" ) @@ -45,6 +46,9 @@ func init() { MaxRetries: cfg.MaxRetries, PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second, ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second, + MaintNotificationsConfig: &maintnotifications.Config{ + Mode: maintnotifications.ModeDisabled, + }, }) log.Println("[Redis] initialized in Cluster mode") } else { @@ -63,6 +67,9 @@ func init() { MaxRetries: cfg.MaxRetries, PoolTimeout: time.Duration(cfg.PoolTimeout) * time.Second, ConnMaxIdleTime: time.Duration(cfg.ConnMaxIdleTime) * time.Second, + MaintNotificationsConfig: &maintnotifications.Config{ + Mode: maintnotifications.ModeDisabled, + }, }) if cfg.MasterName != "" { log.Println("[Redis] initialized in Sentinel mode") diff --git a/internal/model/task_execution_test.go b/internal/model/task_execution_test.go index 87c4040b..d7298f32 100644 --- a/internal/model/task_execution_test.go +++ b/internal/model/task_execution_test.go @@ -14,6 +14,7 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/glebarez/sqlite" "github.com/redis/go-redis/v9" + "github.com/redis/go-redis/v9/maintnotifications" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gorm.io/gorm" @@ -30,7 +31,12 @@ func setupTaskExecutionTestEnvironment(t *testing.T) func() { miniRedis, err := miniredis.Run() require.NoError(t, err) - redisClient := redis.NewClient(&redis.Options{Addr: miniRedis.Addr()}) + redisClient := redis.NewClient(&redis.Options{ + Addr: miniRedis.Addr(), + MaintNotificationsConfig: &maintnotifications.Config{ + Mode: maintnotifications.ModeDisabled, + }, + }) db.SetDB(sqliteDB) db.Redis = redisClient diff --git a/internal/testhelper/test_helper.go b/internal/testhelper/test_helper.go index 6c68de4c..dae5323e 100644 --- a/internal/testhelper/test_helper.go +++ b/internal/testhelper/test_helper.go @@ -14,6 +14,7 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/glebarez/sqlite" "github.com/redis/go-redis/v9" + "github.com/redis/go-redis/v9/maintnotifications" "gorm.io/gorm" ) @@ -62,6 +63,9 @@ func SetupTestEnvironment(t *testing.T) (*gorm.DB, *miniredis.Miniredis, func()) // Hook up Redis Client to miniredis redisClient := redis.NewClient(&redis.Options{ Addr: mr.Addr(), + MaintNotificationsConfig: &maintnotifications.Config{ + Mode: maintnotifications.ModeDisabled, + }, }) db.Redis = redisClient