From be40affb0cf3ceb324b5f270558d7b537a6a6603 Mon Sep 17 00:00:00 2001 From: Xiaochen Wang Date: Thu, 10 Oct 2024 17:48:14 +0800 Subject: [PATCH] dont return the default value from select_by_name for dbless mode --- kong/db/dao/workspaces.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kong/db/dao/workspaces.lua b/kong/db/dao/workspaces.lua index f6d7f1b127d3..659b98bc9255 100644 --- a/kong/db/dao/workspaces.lua +++ b/kong/db/dao/workspaces.lua @@ -5,7 +5,6 @@ local constants = require("kong.constants") local lmdb = require("resty.lmdb") -local DECLARATIVE_DEFAULT_WORKSPACE_ID = constants.DECLARATIVE_DEFAULT_WORKSPACE_ID local DECLARATIVE_DEFAULT_WORKSPACE_KEY = constants.DECLARATIVE_DEFAULT_WORKSPACE_KEY @@ -28,8 +27,12 @@ end function Workspaces:select_by_name(key, options) if kong.configuration.database == "off" and key == "default" then + -- We can ensure that when starting in dbless mode, lmdb will by default + -- insert a 'default' workspace. If this Kong is a dataplane, it will later + -- synchronize the configuration from the CP and overwrite this default one. + -- -- it should be a table, not a single string - return { id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY) or DECLARATIVE_DEFAULT_WORKSPACE_ID, } + return { id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY), } end return self.super.select_by_name(self, key, options)