Skip to content

Commit 12faff9

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 12faff9

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
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()");

proxy/http/remap/UrlRewrite.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,11 @@ UrlRewrite::BuildTable(const char *path)
656656
temporary_redirects.hash_lookup.reset(new URLTable);
657657
forward_mappings_with_recv_port.hash_lookup.reset(new URLTable);
658658

659+
int zret = 0;
660+
659661
if (!remap_parse_config(path, this)) {
660662
// XXX handle file reload error
661-
return 3;
663+
zret = 3;
662664
}
663665

664666
// Destroy unused tables
@@ -686,7 +688,7 @@ UrlRewrite::BuildTable(const char *path)
686688
forward_mappings_with_recv_port.hash_lookup.reset(nullptr);
687689
}
688690

689-
return 0;
691+
return zret;
690692
}
691693

692694
/**

0 commit comments

Comments
 (0)