Skip to content

Commit

Permalink
remove some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
KayzzzZ committed Dec 16, 2024
1 parent 428f620 commit ad2d5da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
12 changes: 6 additions & 6 deletions core/ebpf/eBPFServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ void eBPFServer::Init() {
mAdminConfig.LoadEbpfConfig(configJson);
mEventCB = std::make_unique<EventHandler>(nullptr, -1, 0);
mHostMetadataCB = std::make_unique<HostMetadataHandler>(nullptr, -1, 0);
#ifdef __ENTERPRISE__
mMeterCB = std::make_unique<ArmsMeterHandler>(nullptr, -1, 0);
mSpanCB = std::make_unique<ArmsSpanHandler>(nullptr, -1, 0);
mHostMetadataCB->RegisterUpdatePluginCallback([&](nami::PluginType type, UpdataType updateType, const std::variant<SecurityOptions*, nami::ObserverNetworkOption*> ops) {
return UpdatePlugin(type, updateType, ops);
});
#ifdef __ENTERPRISE__
mMeterCB = std::make_unique<ArmsMeterHandler>(nullptr, -1, 0);
mSpanCB = std::make_unique<ArmsSpanHandler>(nullptr, -1, 0);
#else
mMeterCB = std::make_unique<OtelMeterHandler>(nullptr, -1, 0);
mSpanCB = std::make_unique<OtelSpanHandler>(nullptr, -1, 0);
Expand Down Expand Up @@ -304,7 +304,7 @@ bool eBPFServer::StartPluginInternal(const std::string& pipeline_name,
};
nconfig.metadata_by_cid_cache_ = [&](const std::string& cid) -> std::unique_ptr<nami::PodMeta> {
auto info = K8sMetadata::GetInstance().GetInfoByContainerIdFromCache(cid);
LOG_INFO(sLogger,
LOG_DEBUG(sLogger,
("cid", cid)
("isNull", info == nullptr)
("appId", info == nullptr ? "null" : info->appId)
Expand All @@ -329,7 +329,7 @@ bool eBPFServer::StartPluginInternal(const std::string& pipeline_name,
};
nconfig.metadata_by_ip_cache_ = [&](const std::string& ip) -> std::unique_ptr<nami::PodMeta> {
auto info = K8sMetadata::GetInstance().GetInfoByIpFromCache(ip);
LOG_INFO(sLogger,
LOG_DEBUG(sLogger,
("ip", ip)
("isNull", info == nullptr)
("appId", info == nullptr ? "null" : info->appId)
Expand Down Expand Up @@ -408,7 +408,7 @@ bool eBPFServer::UpdatePlugin(nami::PluginType type, UpdataType updateType, cons
nconfig.disable_container_ids_ = opts->mDisableCids;
eBPFConfig->config_ = nconfig;
eBPFConfig->type = updateType;
LOG_INFO(sLogger,
LOG_DEBUG(sLogger,
("enable_container_ids_ size", nconfig.enable_container_ids_.size())
("disable_container_ids_ size", nconfig.disable_container_ids_.size()));
break;
Expand Down
10 changes: 5 additions & 5 deletions core/ebpf/handler/ObserveHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void HostMetadataHandler::ReportAgentInfo() {
ReadLock lk(mLock);
for (const auto& [ip, spi] : mHostPods) {
// generate agentinfo
LOG_INFO(sLogger, ("AGENT_INFO appid", spi->mAppId)
LOG_DEBUG(sLogger, ("AGENT_INFO appid", spi->mAppId)
("appname", spi->mAppName)
("ip", spi->mPodIp) ("hostname", spi->mPodName) ("agentVersion", "1.0.0") ("startTs", std::to_string(spi->mStartTime)));
auto logEvent = eventGroup.AddLogEvent();
Expand Down Expand Up @@ -266,7 +266,7 @@ bool HostMetadataHandler::handle(uint32_t pluginIndex, std::vector<std::string>&
auto podInfo = K8sMetadata::GetInstance().GetInfoByIpFromCache(ip);
if (!podInfo || podInfo->appId == "") {
// filter appid ...
LOG_INFO(sLogger, (ip, "cannot fetch pod metadata or doesn't have arms label"));
LOG_DEBUG(sLogger, (ip, "cannot fetch pod metadata or doesn't have arms label"));
continue;
}

Expand All @@ -287,10 +287,10 @@ bool HostMetadataHandler::handle(uint32_t pluginIndex, std::vector<std::string>&
addedContainers.push_back(cid);
}
}
LOG_INFO(sLogger, ("appId", podInfo->appId) ("appName", podInfo->appName) ("podIp", podInfo->podIp) ("podName", podInfo->podName) ("containerId", cids));
LOG_DEBUG(sLogger, ("appId", podInfo->appId) ("appName", podInfo->appName) ("podIp", podInfo->podIp) ("podName", podInfo->podName) ("containerId", cids));
}

LOG_INFO(sLogger, ("begin to update local host metadata, pod list size:", newPodIps.size()) ("input pod list size", podIpVec.size()) ("host pod list size", mHostPods.size()));
LOG_DEBUG(sLogger, ("begin to update local host metadata, pod list size:", newPodIps.size()) ("input pod list size", podIpVec.size()) ("host pod list size", mHostPods.size()));

for (auto& cid : mCids) {
if (!currentContainers.count(cid)) {
Expand Down Expand Up @@ -331,7 +331,7 @@ bool HostMetadataHandler::handle(uint32_t pluginIndex, std::vector<std::string>&
ops.mEnableCids = addedContainers;
ops.mEnableCidFilter = true;
bool ret = mUpdateFunc(nami::PluginType::NETWORK_OBSERVE, UpdataType::OBSERVER_UPDATE_TYPE_CHANGE_WHITELIST, &ops);
LOG_INFO(sLogger, ("after update, self pod list size", mHostPods.size())
LOG_DEBUG(sLogger, ("after update, self pod list size", mHostPods.size())
("add cids", addPodsStr)
("remove cids", removePodsStr)
("host pods ip", hostPodsStr)
Expand Down
11 changes: 5 additions & 6 deletions core/metadata/K8sMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,14 @@ void K8sMetadata::DeregisterHostMetadataCallback(uint32_t plugin_index) {
}

void K8sMetadata::LocalHostMetaRefresher() {
LOG_INFO(sLogger, ("enter", "LocalHostMetaRefresher"));
Json::Value jsonObj;
jsonObj["keys"].append(mHostIp);
Json::StreamWriterBuilder writer;
std::string output = Json::writeString(writer, jsonObj);
while(mFlag) {
std::vector<std::string> podIpVec;
bool res = SendRequestToOperator(mServiceHost, output, containerInfoType::HostInfo, podIpVec);
LOG_INFO(sLogger, ("begin to fetch localhost pod metadata, host", mHostIp) ("status", res));
LOG_DEBUG(sLogger, ("begin to fetch localhost pod metadata, host", mHostIp) ("status", res));

// do callbacks
if (res && podIpVec.size()) {
Expand Down Expand Up @@ -203,9 +202,9 @@ bool K8sMetadata::SendRequestToOperator(const std::string& urlHost,

request = std::make_unique<HttpRequest>(
"GET", false, mServiceHost, mServicePort, path, "", map<std::string, std::string>({{"Content-Type","application/json"}}), query, 1, 3);
LOG_INFO(sLogger, ("host", mServiceHost)("port", mServicePort)("path", path)("query", query));
LOG_DEBUG(sLogger, ("host", mServiceHost)("port", mServicePort)("path", path)("query", query));
bool success = SendHttpRequest(std::move(request), res);
LOG_INFO(sLogger, ("res body", *res.GetBody<std::string>()));
LOG_DEBUG(sLogger, ("res body", *res.GetBody<std::string>()));
if (success) {
if (res.GetStatusCode() != 200) {
LOG_WARNING(sLogger, ("fetch k8s meta from one operator fail, code is ", res.GetStatusCode()));
Expand Down Expand Up @@ -304,7 +303,7 @@ void K8sMetadata::SetIpCache(const Json::Value& root) {
}

void K8sMetadata::SetExternalIpCache(const std::string& ip) {
LOG_INFO(sLogger, (ip, "is external, inset into cache ..."));
LOG_DEBUG(sLogger, (ip, "is external, inset into cache ..."));
externalIpCache.insert(ip, uint8_t(0));
}

Expand Down Expand Up @@ -400,7 +399,7 @@ std::vector<std::shared_ptr<k8sContainerInfo>> K8sMetadata::SyncGetPodMetadataBy
for (size_t i = 0 ; i < ips.size(); i ++ ) {
if (IsExternalIp(ips[i])) {
result[i] = nullptr;
LOG_INFO(sLogger, (ips[i], "external, set nullptr to metadata"));
LOG_DEBUG(sLogger, (ips[i], "external, set nullptr to metadata"));
continue;
}
auto info = GetInfoByIpFromCache(ips[i]);
Expand Down

0 comments on commit ad2d5da

Please sign in to comment.