Skip to content

Commit f605cf4

Browse files
committed
Short circuit remap reload when a valid remap file is not specified
Ensures resiliency against config errors erasing remaps previously loaded. Note that failing to load remap.config during startup will no longer fail the TS startup to allow for optionality in remap.config. The missing remaps would need to be detected via functional tests
1 parent 1994737 commit f605cf4

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

proxy/ReverseProxy.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ init_reverse_proxy()
6767

6868
Note("%s loading ...", ts::filename::REMAP);
6969
if (!rewrite_table->load()) {
70-
Fatal("%s failed to load", ts::filename::REMAP);
70+
Warning("%s failed to load", ts::filename::REMAP);
71+
} else {
72+
Note("%s finished loading", ts::filename::REMAP);
7173
}
72-
Note("%s finished loading", ts::filename::REMAP);
7374

7475
REC_RegisterConfigUpdateFunc("proxy.config.url_remap.filename", url_rewrite_CB, (void *)FILE_CHANGED);
7576
REC_RegisterConfigUpdateFunc("proxy.config.proxy_name", url_rewrite_CB, (void *)TSNAME_CHANGED);

proxy/http/remap/RemapConfig.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,9 @@ remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti)
945945

946946
std::error_code ec;
947947
std::string content{ts::file::load(ts::file::path{path}, ec)};
948-
if (ec) {
949-
switch (ec.value()) {
950-
case ENOENT:
951-
Warning("Can't open remapping configuration file %s - %s", path, strerror(ec.value()));
952-
break;
953-
default:
954-
Error("Failed load remapping configuration file %s - %s", path, strerror(ec.value()));
955-
return false;
956-
}
948+
if (ec.value()) {
949+
Warning("Failed to open remapping configuration file %s - %s", path, strerror(ec.value()));
950+
return false;
957951
}
958952

959953
Debug("url_rewrite", "[BuildTable] UrlRewrite::BuildTable()");

0 commit comments

Comments
 (0)