From 052fe52489b5f371044e4d11b7d30014ae82af76 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Fri, 27 Oct 2023 10:15:35 +0200 Subject: [PATCH] ADD: added some details to error logs --- src/kubecontrol/PodController.cpp | 24 +++++++++++++++++++----- src/kubecontrol/PodInfo.cpp | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/kubecontrol/PodController.cpp b/src/kubecontrol/PodController.cpp index e8a5672..8c7b91b 100644 --- a/src/kubecontrol/PodController.cpp +++ b/src/kubecontrol/PodController.cpp @@ -1,4 +1,5 @@ +#include "curlpp/Options.hpp" #include "kubecontrol/PodInfo.hpp" #include "nlohmann/json_fwd.hpp" #include @@ -94,17 +95,20 @@ namespace kubecontrol return response; } - std::string PodController::getPodsInfo( ) + std::string PodController::getPodsInfo() { std::string curlURL = ServerAddress_+ApiCall_; - auto response = this->performRequest(curlURL); + std::string response = this->performRequest(curlURL); std::vector podsNames; + nlohmann::json j; + try + { - auto j = nlohmann::json::parse(response); + j = nlohmann::json::parse(response); if (j.contains("items")) { @@ -114,6 +118,7 @@ namespace kubecontrol if (!j["items"][a]["metadata"]["name"].empty()) { podsNames.emplace_back(j["items"][a]["metadata"]["name"]); + } } } @@ -130,11 +135,18 @@ namespace kubecontrol 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) { + bool found = false; for (auto item : PodList_) { @@ -144,6 +156,7 @@ namespace kubecontrol checkPodsHierarchy(); item.InfoPod = *getPodInfo(item.getUUID()).get(); LOG_S(INFO)<Uuid == uuid) { - return podsInfoList_[i]; + return podsInfoList_[i]; } } return nullptr; @@ -280,6 +293,7 @@ namespace kubecontrol WriterMemoryClass mWriterChunk; 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); + request->setOpt(test); request->setOpt(new curlpp::options::HttpHeader(headers)); diff --git a/src/kubecontrol/PodInfo.cpp b/src/kubecontrol/PodInfo.cpp index c320edf..a77f9c3 100644 --- a/src/kubecontrol/PodInfo.cpp +++ b/src/kubecontrol/PodInfo.cpp @@ -58,7 +58,7 @@ namespace kubecontrol } catch (std::exception& e) { // LOG_S(WARNING)<< response; - LOG_S(ERROR)<