Skip to content

Commit 0d3a262

Browse files
fix(cli) don't overwrite config files on migration commands (Kong#7017)
The nginx configuration files are usually rewritten from configuration and template on each restart/reload. This also happens on `migration` commands, as part of the configuration loading. This can be undesirable, especially when using a custom templace, since these commands don't admit a `--nginx-conf` argument, so they always use the default template, reverting customization. Given that these commands don't restart/reload the nginx process, there's no benefit in writing the config files. This patch skips the writing (and verifying) steps on those commands.
1 parent 79c6d83 commit 0d3a262

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kong/cmd/migrations.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ local function execute(args)
9393
conf.cassandra_timeout = args.db_timeout -- connect + send + read
9494
conf.cassandra_schema_consensus_timeout = args.db_timeout
9595

96-
assert(prefix_handler.prepare_prefix(conf, args.nginx_conf))
96+
assert(prefix_handler.prepare_prefix(conf, args.nginx_conf, true))
9797

9898
_G.kong = kong_global.new()
9999
kong_global.init_pdk(_G.kong, conf, nil) -- nil: latest PDK

kong/cmd/utils/prefix_handler.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ local function compile_nginx_conf(kong_config, template)
325325
return compile_conf(kong_config, template)
326326
end
327327

328-
local function prepare_prefix(kong_config, nginx_custom_template_path)
328+
local function prepare_prefix(kong_config, nginx_custom_template_path, skip_write)
329329
log.verbose("preparing nginx prefix directory at %s", kong_config.prefix)
330330

331331
if not pl_path.exists(kong_config.prefix) then
@@ -414,6 +414,10 @@ local function prepare_prefix(kong_config, nginx_custom_template_path)
414414
[[ to at least "4096" using "ulimit -n"]], ulimit)
415415
end
416416

417+
if skip_write then
418+
return true
419+
end
420+
417421
-- compile Nginx configurations
418422
local nginx_template
419423
if nginx_custom_template_path then

0 commit comments

Comments
 (0)