Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/metadata #1768

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

NameHaibinZhang
Copy link

add k8s metadata

@@ -0,0 +1,245 @@
/*
* LRUCache11 - a templated C++11 based LRU cache class that allows
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::cerr << "Failed to parse JSON: " << errors << std::endl;
return;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空行

// Copyright 2022 iLogtail Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名大小写

for (const auto& key : json["labels"].getMemberNames()) {
if (json["labels"].isMember(key)) {
info.labels[key] = json["labels"][key].asString();
if (key == "armsAppId") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能直接有arms的变量,具体处理策略core/ebpf/handler/ObserveHandler.cpp

std::chrono::system_clock::time_point th2 = std::chrono::system_clock::from_time_t(now);
std::chrono::duration<double> diff = th2 - th1;
double minutes_diff = diff.count() / 60.0;
if (minutes_diff > 10) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成用乘法作比较

FromContainerJson(root, data);
for (const auto& pair : data->containers) {
if (infoType == containerInfoType::ContainerIdInfo) {
containerCache.insert(pair.first, std::make_shared<k8sContainerInfo>(pair.second));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并发的考虑

return;
}
FromContainerJson(root, data);
for (const auto& pair : data->containers) {
Copy link
Collaborator

@messixukejia messixukejia Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containers没有老化机制?只增不删?


if (reader->parse(res.mBody.c_str(), res.mBody.c_str() + res.mBody.size(), &root, &errors)) {
std::shared_ptr<ContainerData> data = std::make_shared<ContainerData>();
FromContainerJson(root, data);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FromContainerJson 外部输入都是不可靠的

}
Json::StreamWriterBuilder writer;
std::string output = Json::writeString(writer, jsonObj);
SendRequestToOperator(mServiceHost, output, containerInfoType::ContainerIdInfo);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SendRequestToOperator 失败机制也不统一

}
request = std::make_unique<HttpRequest>("GET", false, mServiceHost, mServicePort, path, "", map<std::string, std::string>(), output, 30, 3);
bool success = SendHttpRequest(std::move(request), res);
if (res.mStatusCode != 200) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

success跟res.mStatusCode的顺序是什么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants