ADD: added some details to error logs
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
#include "curlpp/Options.hpp"
|
||||||
#include "kubecontrol/PodInfo.hpp"
|
#include "kubecontrol/PodInfo.hpp"
|
||||||
#include "nlohmann/json_fwd.hpp"
|
#include "nlohmann/json_fwd.hpp"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@@ -94,17 +95,20 @@ namespace kubecontrol
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PodController::getPodsInfo( )
|
std::string PodController::getPodsInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string curlURL = ServerAddress_+ApiCall_;
|
std::string curlURL = ServerAddress_+ApiCall_;
|
||||||
|
|
||||||
auto response = this->performRequest(curlURL);
|
std::string response = this->performRequest(curlURL);
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> podsNames;
|
std::vector<std::string> podsNames;
|
||||||
|
nlohmann::json j;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
auto j = nlohmann::json::parse(response);
|
j = nlohmann::json::parse(response);
|
||||||
|
|
||||||
if (j.contains("items"))
|
if (j.contains("items"))
|
||||||
{
|
{
|
||||||
@@ -114,6 +118,7 @@ namespace kubecontrol
|
|||||||
if (!j["items"][a]["metadata"]["name"].empty())
|
if (!j["items"][a]["metadata"]["name"].empty())
|
||||||
{
|
{
|
||||||
podsNames.emplace_back(j["items"][a]["metadata"]["name"]);
|
podsNames.emplace_back(j["items"][a]["metadata"]["name"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,11 +135,18 @@ namespace kubecontrol
|
|||||||
|
|
||||||
|
|
||||||
return j.dump();
|
return j.dump();
|
||||||
|
|
||||||
|
}catch(const std::exception e)
|
||||||
|
{
|
||||||
|
LOG_S(ERROR)<< e.what()<< " IN PodController::getPodsInfo() Function";
|
||||||
|
}
|
||||||
|
return j.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string PodController::getInfoForPod(std::string Label)
|
std::string PodController::getInfoForPod(std::string Label)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto item : PodList_)
|
for (auto item : PodList_)
|
||||||
{
|
{
|
||||||
@@ -144,6 +156,7 @@ namespace kubecontrol
|
|||||||
checkPodsHierarchy();
|
checkPodsHierarchy();
|
||||||
item.InfoPod = *getPodInfo(item.getUUID()).get();
|
item.InfoPod = *getPodInfo(item.getUUID()).get();
|
||||||
LOG_S(INFO)<<item.InfoPod.getRelatedPods().size();
|
LOG_S(INFO)<<item.InfoPod.getRelatedPods().size();
|
||||||
|
|
||||||
return item.getInfo(ServerAddress_+ApiCall_, BearerToken_);
|
return item.getInfo(ServerAddress_+ApiCall_, BearerToken_);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -207,7 +220,7 @@ namespace kubecontrol
|
|||||||
|
|
||||||
} catch (std::exception& e)
|
} catch (std::exception& e)
|
||||||
{
|
{
|
||||||
LOG_S(ERROR)<<e.what();
|
LOG_S(ERROR)<<e.what() << " In checkPodsHierarchy() Function";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -242,7 +255,7 @@ namespace kubecontrol
|
|||||||
|
|
||||||
if (podsInfoList_[i]->Uuid == uuid)
|
if (podsInfoList_[i]->Uuid == uuid)
|
||||||
{
|
{
|
||||||
return podsInfoList_[i];
|
return podsInfoList_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -280,6 +293,7 @@ namespace kubecontrol
|
|||||||
WriterMemoryClass mWriterChunk;
|
WriterMemoryClass mWriterChunk;
|
||||||
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
curlpp::types::WriteFunctionFunctor functor = std::bind(&WriterMemoryClass::WriteMemoryCallback, &mWriterChunk, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor);
|
||||||
|
|
||||||
request->setOpt(test);
|
request->setOpt(test);
|
||||||
|
|
||||||
request->setOpt(new curlpp::options::HttpHeader(headers));
|
request->setOpt(new curlpp::options::HttpHeader(headers));
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace kubecontrol
|
|||||||
} catch (std::exception& e)
|
} catch (std::exception& e)
|
||||||
{
|
{
|
||||||
// LOG_S(WARNING)<< response;
|
// LOG_S(WARNING)<< response;
|
||||||
LOG_S(ERROR)<<e.what();
|
LOG_S(ERROR)<<e.what() << " IN PodInfo Constructor";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user