-
Notifications
You must be signed in to change notification settings - Fork 579
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
Fix broken downtime comment sync #10000
base: master
Are you sure you want to change the base?
Conversation
Quick question: would this also fix the following issue: |
It would be very helpful to get an answer to this. |
Hi, we don't know for sure whether this will fix #10078 as we still haven't identified exactly what is going wrong there, other than something is not working as expected. It's unlikely that this PR will fix #10078, but we can't tell you for sure until the cause for #10078 is identified. |
@yhabteab When will this request be completed? Is there a timeline? |
e3c289f
to
78095b8
Compare
cb4fe57
to
eb97676
Compare
I believe similar problems will still exist for other types where there's no |
8645d1e
to
1261254
Compare
1261254
to
163964f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I've overseen an elephant, despite I like small diffs. Sorry😅
845a61b
to
2fd478a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFTM
3254f36
to
770b730
Compare
Fortunately, @julianbrost found out during testing that the objects are not being synchronised in the correct order, as they are supposed to be with this PR. Thus, I made some modifications in the Before[2024-12-04 08:45:47 +0100] critical/config: Error: Validation failed for object 'dsl-groups' of type 'HostGroup'; Attribute 'groups': Object 'dns-groups' of type 'HostGroup' does not exist.
Location: in /Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf: 2:2-2:26
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(1): object HostGroup "dsl-groups" {
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(2): groups = [ "dns-groups" ]
^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(3): version = 1733298340.337465
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(4): zone = "master"
[2024-12-04 08:45:47 +0100] critical/config: 1 error
[2024-12-04 08:45:47 +0100] critical/ApiListener: Could not create object 'dsl-groups':
[2024-12-04 08:45:47 +0100] critical/ApiListener: Error: Validation failed for object 'dsl-groups' of type 'HostGroup'; Attribute 'groups': Object 'dns-groups' of type 'HostGroup' does not exist.
Location: in /Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf: 2:2-2:26
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(1): object HostGroup "dsl-groups" {
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(2): groups = [ "dns-groups" ]
^^^^^^^^^^^^^^^^^^^^^^^^^
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(3): version = 1733298340.337465
/Users/yhabteab/ClionProjects/icinga2/prefix/var/lib/icinga2/api/packages/_api/354bb4c7-3d94-4df3-bba3-add86e471cd3/conf.d/hostgroups/dsl-groups.conf(4): zone = "master"
[2024-12-04 08:45:47 +0100] information/ConfigObjectUtility: Created and activated object 'dns-groups' of type 'HostGroup'. After[2024-12-04 08:51:01 +0100] information/ApiListener: Copying file 'master//_etc/overflow.conf' from config sync staging to production zones directory.
[2024-12-04 08:51:01 +0100] information/ApiListener: Copying file 'master//_etc/services.conf' from config sync staging to production zones directory.
[2024-12-04 08:51:02 +0100] information/ConfigObjectUtility: Created and activated object 'dns-groups' of type 'HostGroup'.
[2024-12-04 08:51:02 +0100] information/ConfigObjectUtility: Created and activated object 'dsl-groups' of type 'HostGroup'.
[2024-12-04 08:51:03 +0100] information/Application: Got reload command: Starting new instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boost::multi_index::indexed_by< | ||
// The first indexer is used for lookups by the Edge object itself, thus it | ||
// needs its own hash function and comparison predicate. | ||
boost::multi_index::hashed_non_unique<boost::multi_index::identity<Edge>, Edge::HashPredicate, Edge::HashPredicate>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why NON unique if you don't use this as multi-map anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But let's keep this IF you'll use this as multimap. (#10000 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why NON unique if you don't use this as multi-map anyway?
Especially given there IS a unique version.
770b730
to
dd6f9b9
Compare
|
||
if (it->second == 0) | ||
refs.erase(it); | ||
std::unique_lock<std::mutex> lock(m_Mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional
std::unique_lock<std::mutex> lock(m_Mutex); | |
std::unique_lock lock(m_Mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional, but highly desired for NEW code which won't be backported to v2.13. (Doesn't CLion annoy you like ugh can be omitted?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any doubt that the terminology used so far by DependencyGraph
is misleading? This terminology has caused confusion in the past (it was overlooked for quite some time that it returned the opposite direction from what was needed/expected in this PR), causes confusion right no (it makes my head hurt while looking at the PR) and will almost certainly cause more confusion in the future.
To keep this naming, you already have added multiple "this is stupid naming and should be the opposite" comments and I believe it would need even more warnings (basically the same warning/explanation of a strange child/parent definition for each method) that it raises the question why we shouldn't simply fix the terminology instead. Alternative would be to use better naming for the new wording for the new method to leave the existing callers untouched (something like GetRequirementsOf()
for the new method), but mixing that sounds like another recipe for confusion.
struct HashPredicate | ||
{ | ||
/** | ||
* Generates a unique hash of the given Edge object. | ||
* | ||
* Note, the hash value is generated only by combining the hash values of the parent and child pointers. | ||
* | ||
* @param edge The Edge object to be hashed. | ||
* | ||
* @return size_t The resulting hash value of the given object. | ||
*/ | ||
size_t operator()(const Edge& edge) const | ||
{ | ||
size_t seed = 0; | ||
boost::hash_combine(seed, edge.parent); | ||
boost::hash_combine(seed, edge.child); | ||
|
||
return seed; | ||
} | ||
|
||
/** | ||
* Compares whether the two Edge objects contain the same parent and child pointers. | ||
* | ||
* Note, the member property count is not taken into account for equality checks. | ||
* | ||
* @param a The first Edge object to compare. | ||
* @param b The second Edge object to compare. | ||
* | ||
* @return bool Returns true if the two objects are equal, false otherwise. | ||
*/ | ||
bool operator()(const Edge& a, const Edge& b) const | ||
{ | ||
return a.parent == b.parent && a.child == b.child; | ||
} | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combining both these operations in a single type technically works, but it quite uncommon. You'd typically define two separate types so that you have Hash::operator()
and Equal::operator()
to do the corresponding operation (and it's clear without function overloading). That's also the reason there are two template argument.
// The first indexer is used for lookups by the Edge object itself, thus it | ||
// needs its own hash function and comparison predicate. | ||
boost::multi_index::hashed_non_unique<boost::multi_index::identity<Edge>, Edge::HashPredicate, Edge::HashPredicate>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"by the Edge object itself" is a bit vague as Edge
includes count
which isn't included in the lookup. I'd rather say something like "the edge from child to parent".
// The second and third indexers are used for lookups by the parent and child pointers. | ||
boost::multi_index::hashed_non_unique<boost::multi_index::member<Edge, Object*, &Edge::parent>>, | ||
boost::multi_index::hashed_non_unique<boost::multi_index::member<Edge, Object*, &Edge::child>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saying first/second/third here is somewhat confusing as accessing them is 0-indexed.
|
boost::multi_index::indexed_by< | ||
// The first indexer is used for lookups by the Edge object itself, thus it | ||
// needs its own hash function and comparison predicate. | ||
boost::multi_index::hashed_non_unique<boost::multi_index::identity<Edge>, Edge::HashPredicate, Edge::HashPredicate>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why NON unique if you don't use this as multi-map anyway?
Especially given there IS a unique version.
|
||
if (it->second == 0) | ||
refs.erase(it); | ||
std::unique_lock<std::mutex> lock(m_Mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional, but highly desired for NEW code which won't be backported to v2.13. (Doesn't CLion annoy you like ugh can be omitted?)
All objects must be synced sorted by their load dependency. Otherwise, downtimes and/or comments might get synced before their respective Checkables, which will result in comments and downtimes being ignored by the other endpoint since it does not yet know about their checkables. Given that the runtime config updates event does not trigger a reload on the remote endpoint, these objects won't be synced again until the next reload.
After master2 reload:
closes #7786
closes #9873
TODO