Jul 23rd update

This commit is contained in:
Ned Wright
2024-07-23 11:08:24 +00:00
parent 57ea5c72c5
commit f58e9a6128
17 changed files with 172 additions and 38 deletions

View File

@@ -71,6 +71,7 @@ public:
bool addAttr(const string &key, const string &val, bool allow_override = false) override;
bool addAttr(const map<string, string> &attr, bool allow_override = false) override;
void deleteAttr(const string &key) override;
bool isPersistantAttr(const string &key) override;
bool sendAttributes() override;
@@ -130,6 +131,7 @@ private:
map<string, string> persistant_attributes;
map<string, string> new_attributes;
map<string, string> attributes;
bool is_attr_deleted = false;
I_Messaging *messaging = nullptr;
bool is_server;
@@ -207,6 +209,13 @@ AgentDetailsReporter::Impl::deleteAttr(const string &key)
attributes.erase(key);
new_attributes.erase(key);
persistant_attributes.erase(key);
is_attr_deleted = true;
}
bool
AgentDetailsReporter::Impl::isPersistantAttr(const std::string &key)
{
return persistant_attributes.count(key) > 0;
}
bool
@@ -214,7 +223,7 @@ AgentDetailsReporter::Impl::sendAttributes()
{
dbgDebug(D_AGENT_DETAILS) << "Trying to send attributes";
if (new_attributes.empty()) {
if (new_attributes.empty() && !is_attr_deleted) {
dbgDebug(D_AGENT_DETAILS) << "Skipping current attempt since no new attributes were added";
return true;
}
@@ -261,6 +270,7 @@ AgentDetailsReporter::Impl::sendAttributes()
if (add_agent_details_status.ok()) {
dbgDebug(D_AGENT_DETAILS) << "Successfully sent attributes to the Orchestrator";
new_attributes.clear();
is_attr_deleted = false;
return true;
}

View File

@@ -213,6 +213,7 @@ TEST_F(AgentReporterTest, basicAttrTest)
EXPECT_TRUE(report->addAttr({{"c", "d"}, {"1", "2"}, {"delete", "me"}}));
EXPECT_FALSE(report->addAttr("a", "d"));
EXPECT_TRUE(report->addAttr("a", "1", true));
EXPECT_TRUE(report->isPersistantAttr("a"));
report->deleteAttr("delete");
{
AgentDataReport agent_data;

View File

@@ -108,7 +108,10 @@ HttpAttachmentConfiguration::save(cereal::JSONOutputArchive &archive) const
),
cereal::make_nvp("nginx_inspection_mode", getNumericalValue("inspection_mode")),
cereal::make_nvp("num_of_nginx_ipc_elements", getNumericalValue("num_of_nginx_ipc_elements")),
cereal::make_nvp("keep_alive_interval_msec", getNumericalValue("keep_alive_interval_msec"))
cereal::make_nvp("keep_alive_interval_msec", getNumericalValue("keep_alive_interval_msec")),
cereal::make_nvp("min_retries_for_verdict", getNumericalValue("min_retries_for_verdict")),
cereal::make_nvp("max_retries_for_verdict", getNumericalValue("max_retries_for_verdict")),
cereal::make_nvp("body_size_trigger", getNumericalValue("body_size_trigger"))
);
}
@@ -161,6 +164,9 @@ HttpAttachmentConfiguration::load(cereal::JSONInputArchive &archive)
loadNumericalValue(archive, "nginx_inspection_mode", 0);
loadNumericalValue(archive, "num_of_nginx_ipc_elements", 200);
loadNumericalValue(archive, "keep_alive_interval_msec", DEFAULT_KEEP_ALIVE_INTERVAL_MSEC);
loadNumericalValue(archive, "min_retries_for_verdict", 3);
loadNumericalValue(archive, "max_retries_for_verdict", 15);
loadNumericalValue(archive, "body_size_trigger", 200000);
}
bool

View File

@@ -54,6 +54,9 @@ unsigned int getReqBodyThreadTimeout();
unsigned int getResProccessingTimeout();
unsigned int getResHeaderThreadTimeout();
unsigned int getResBodyThreadTimeout();
unsigned int getMinRetriesForVerdict();
unsigned int getMaxRetriesForVerdict();
unsigned int getReqBodySizeTrigger();
unsigned int getWaitingForVerdictThreadTimeout();

View File

@@ -48,6 +48,7 @@ public:
virtual bool addAttr(const std::map<std::string, std::string> &attr, bool allow_override = false) = 0;
virtual void deleteAttr(const std::string &key) = 0;
virtual bool sendAttributes() = 0;
virtual bool isPersistantAttr(const std::string &key) = 0;
protected:
~I_AgentDetailsReporter() = default;

View File

@@ -26,6 +26,7 @@ public:
MOCK_METHOD3(addAttr, bool(const std::string &key, const std::string &val, bool allow_override));
MOCK_METHOD2(addAttr, bool(const std::map<std::string, std::string> &attr, bool allow_override));
MOCK_METHOD1(deleteAttr, void(const std::string &key));
MOCK_METHOD1(isPersistantAttr, bool(const std::string &key));
MOCK_METHOD0(sendAttributes, bool());
};