Skip to content

Commit

Permalink
[Bug] BE download_files function exists log print sensitive msg apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
LuGuangming committed Dec 18, 2023
1 parent 97e6351 commit 4495f81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions be/src/olap/task/engine_clone_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <regex>

#include "common/config.h"
#include "common/logging.h"
Expand Down Expand Up @@ -390,7 +391,7 @@ Status EngineCloneTask::_make_and_download_snapshots(DataDir& data_dir,
status = _download_files(&data_dir, remote_url_prefix, local_data_path);
if (!status.ok()) [[unlikely]] {
LOG_WARNING("failed to download snapshot from remote BE")
.tag("url", remote_url_prefix)
.tag("url", _mask_token(remote_url_prefix))
.error(status);
continue; // Try another BE
}
Expand Down Expand Up @@ -526,11 +527,11 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re

std::string local_file_path = local_path + "/" + file_name;

LOG(INFO) << "clone begin to download file from: " << remote_file_url
LOG(INFO) << "clone begin to download file from: " << _mask_token(remote_file_url)
<< " to: " << local_file_path << ". size(B): " << file_size
<< ", timeout(s): " << estimate_timeout;

auto download_cb = [&remote_file_url, estimate_timeout, &local_file_path,
auto download_cb = [this, &remote_file_url, estimate_timeout, &local_file_path,
file_size](HttpClient* client) {
RETURN_IF_ERROR(client->init(remote_file_url));
client->set_timeout_ms(estimate_timeout * 1000);
Expand All @@ -546,7 +547,7 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re
}
if (local_file_size != file_size) {
LOG(WARNING) << "download file length error"
<< ", remote_path=" << remote_file_url << ", file_size=" << file_size
<< ", remote_path=" << _mask_token(remote_file_url) << ", file_size=" << file_size
<< ", local_file_size=" << local_file_size;
return Status::InternalError("downloaded file size is not equal");
}
Expand Down Expand Up @@ -827,4 +828,9 @@ Status EngineCloneTask::_finish_full_clone(Tablet* tablet,
// TODO(plat1ko): write cooldown meta to remote if this replica is cooldown replica
}

std::string _mask_token(const std::string& str) {
std::regex pattern("token=[\\w|-]+");
return regex_replace(str, pattern, "token=******");
}

} // namespace doris
2 changes: 2 additions & 0 deletions be/src/olap/task/engine_clone_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class EngineCloneTask : public EngineTask {
bool* allow_incremental_clone);

Status _release_snapshot(const std::string& ip, int port, const std::string& snapshot_path);

std::string _mask_token(const std::string& str);

private:
const TCloneReq& _clone_req;
Expand Down

0 comments on commit 4495f81

Please sign in to comment.