mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Merge pull request #9301 from Icinga/bugfix/icingadb-remove-comment-history-2.13
Icinga DB: discard comment removals with missing information
This commit is contained in:
commit
5a65190d02
@ -2026,6 +2026,21 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double removeTime = comment->GetRemoveTime();
|
||||||
|
bool wasRemoved = removeTime > 0;
|
||||||
|
|
||||||
|
double expireTime = comment->GetExpireTime();
|
||||||
|
bool hasExpireTime = expireTime > 0;
|
||||||
|
bool isExpired = hasExpireTime && expireTime <= Utility::GetTime();
|
||||||
|
|
||||||
|
if (!wasRemoved && !isExpired) {
|
||||||
|
/* The comment object disappeared for no apparent reason, most likely because it simply was deleted instead
|
||||||
|
* of using the proper remove-comment API action. In this case, information that should normally be set is
|
||||||
|
* missing and a proper history event cannot be generated.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto checkable (comment->GetCheckable());
|
auto checkable (comment->GetCheckable());
|
||||||
|
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
@ -2064,8 +2079,7 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
|
|||||||
xAdd.emplace_back(GetObjectIdentifier(endpoint));
|
xAdd.emplace_back(GetObjectIdentifier(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
double removeTime = comment->GetRemoveTime();
|
if (wasRemoved) {
|
||||||
if (removeTime > 0) {
|
|
||||||
xAdd.emplace_back("remove_time");
|
xAdd.emplace_back("remove_time");
|
||||||
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(removeTime)));
|
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(removeTime)));
|
||||||
xAdd.emplace_back("has_been_removed");
|
xAdd.emplace_back("has_been_removed");
|
||||||
@ -2077,14 +2091,10 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
|
|||||||
xAdd.emplace_back("0");
|
xAdd.emplace_back("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (hasExpireTime) {
|
||||||
auto expireTime (comment->GetExpireTime());
|
|
||||||
|
|
||||||
if (expireTime > 0) {
|
|
||||||
xAdd.emplace_back("expire_time");
|
xAdd.emplace_back("expire_time");
|
||||||
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expireTime)));
|
xAdd.emplace_back(Convert::ToString(TimestampToMilliseconds(expireTime)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_HistoryBulker.ProduceOne(std::move(xAdd));
|
m_HistoryBulker.ProduceOne(std::move(xAdd));
|
||||||
UpdateState(checkable, StateUpdate::Full);
|
UpdateState(checkable, StateUpdate::Full);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user