Skip to content
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

DependencyGraph: switch "parent" and "child" terminology #10263

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

Al2Klimov
Copy link
Member

The .ti files call DependencyGraph::AddDependency(this, service.get()). Obviously, service.get() is the parent and this (Downtime, Notification, ...) is the child. The DependencyGraph terminology should reflect this not to confuse its future users.

The .ti files call `DependencyGraph::AddDependency(this, service.get())`. Obviously, `service.get()` is the parent and `this` (Downtime, Notification, ...) is the child. The DependencyGraph terminology should reflect this not to confuse its future users.
@Al2Klimov Al2Klimov added the core/quality Improve code, libraries, algorithms, inline docs label Dec 4, 2024
@Al2Klimov Al2Klimov requested a review from yhabteab December 4, 2024 10:05
@cla-bot cla-bot bot added the cla/signed label Dec 4, 2024
@Al2Klimov Al2Klimov force-pushed the DependencyGraph-parent-child branch from 5547c12 to 188ba53 Compare December 4, 2024 10:22
@Al2Klimov
Copy link
Member Author

@julianbrost
Copy link
Contributor

Note that I didn't specifically request that this PR must be done. For me it would also be totally fine if @yhabteab includes the commit from this PR in #10000 (possibly in an adapted way) or does it differently.

@julianbrost
Copy link
Contributor

I just said that it's up to @yhabteab and #10000 what will happen to this PR, why should I review it now?

@julianbrost julianbrost removed their request for review December 12, 2024 09:22
@Al2Klimov
Copy link
Member Author

Because, in wise foresight, I've done this work even before you requested it. And yes, you requested to "simply fix the terminology" which I've done here – no less no more.

if @yhabteab includes the commit from this PR in #10000

(If not "in an adapted way/differently",) This would look strange to me. Then it lands again, via #10000, on your to-review list anyway.

I just said that it's up to @yhabteab and #10000 what will happen to this PR

But ok. Let's first hear @yhabteab's opinion on this PR.

@@ -520,7 +520,7 @@ String ScriptUtils::MsiGetComponentPathShim(const String& component)

Array::Ptr ScriptUtils::TrackParents(const Object::Ptr& child)
{
return Array::FromVector(DependencyGraph::GetParents(child));
return Array::FromVector(DependencyGraph::GetChildren(child));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is called TrackParents and not children, how is this supposed to work now?

<4> => get_object(Dependency, "brother!mother")
{
	__name = "brother!mother"
	active = true
	child_host_name = "brother"
	child_service_name = ""
	disable_checks = false
	disable_notifications = true
        ....
<5> => track_parents(get_object(Dependency, "brother!mother"))
[ ]
<8> => track_parents(get_host("mother"))
[ {
	__name = "brother!mother"
	active = true
	child_host_name = "brother"
	child_service_name = ""
	disable_checks = false
	disable_notifications = true
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it has never worked, because I literally just renamed methods and method args.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to also fix this, it would be a breaking change. (I'd even drop the method, so that its users notice easily.) But this is something for v2.15, i.e another PR. (And no, I won't open another PR right now, don't worry.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @julianbrost wants to merge this while that DSL function is still broken (was broken before too), then it would probably work as expected with #10000like for the first time since it was introduced :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function looks like a early debugging left-over to me. It's not mentioned in the documentation and from the name track_parents it isn't really clear what it does.

(I'd even drop the method, so that its users notice easily.) But this is something for v2.15

Sounds like what I would do. (If we figure out that there's a real-world use for it, it should probably get a proper name and documentation.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the best discovery tool for real-world usages is removal.😈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes, your fact checking is correct:

$ git grep -nFie track_parents
lib/base/scriptutils.cpp:52:REGISTER_SAFE_FUNCTION(System, track_parents, &ScriptUtils::TrackParents, "child");
$ git grep -nFie track\\_parents
$ git grep -nFie track\\\\_parents
$

Same at Google btw.: https://letmegooglethat.com/?q=%22icinga%22+2+%22track_parents%22

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay 🎉! It works now with d28dfec!

<11> => track_parents(get_object(Dependency, "brother!mother"))
[ {
	__name = "mother"
	acknowledgement = 0.000000
	acknowledgement_expiry = 0.000000
	acknowledgement_last_change = 0.000000
	action_url = ""
	active = true
	address = ""
	address6 = ""
	check_attempt = 1.000000
	check_command = "dummy"
	check_interval = 60.000000
	check_period = ""
	check_timeout = null
	command_endpoint = ""
	display_name = "mother"
	downtime_depth = 0.000000
	enable_active_checks = true
	enable_event_handler = true
	enable_flapping = false
	enable_notifications = true
	enable_passive_checks = true
....

@Al2Klimov Al2Klimov requested a review from yhabteab December 12, 2024 10:10
@Al2Klimov Al2Klimov added this to the 2.15.0 milestone Dec 12, 2024
Copy link
Contributor

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, service.get() is the parent and this (Downtime, Notification, ...) is the child.

For the calls of DependencyGraph::AddDependency() that are done explicitly in source files from the repo.

There are also the usages generated by mkclass:

if (field.Type.ArrayRank > 0) {
m_Impl << "\t" << "if (oldValue) {" << std::endl
<< "\t\t" << "ObjectLock olock(oldValue);" << std::endl
<< "\t\t" << "for (const String& ref : oldValue) {" << std::endl
<< "\t\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject";
/* Ew */
if (field.Type.TypeName == "Zone" && m_Library == "base")
m_Impl << "(\"Zone\", ";
else
m_Impl << "<" << field.Type.TypeName << ">(";
m_Impl << "ref).get());" << std::endl
<< "\t\t" << "}" << std::endl
<< "\t" << "}" << std::endl
<< "\t" << "if (newValue) {" << std::endl
<< "\t\t" << "ObjectLock olock(newValue);" << std::endl
<< "\t\t" << "for (const String& ref : newValue) {" << std::endl
<< "\t\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject";
/* Ew */
if (field.Type.TypeName == "Zone" && m_Library == "base")
m_Impl << "(\"Zone\", ";
else
m_Impl << "<" << field.Type.TypeName << ">(";
m_Impl << "ref).get());" << std::endl
<< "\t\t" << "}" << std::endl
<< "\t" << "}" << std::endl;
} else {
m_Impl << "\t" << "if (!oldValue.IsEmpty())" << std::endl
<< "\t\t" << "DependencyGraph::RemoveDependency(this, ConfigObject::GetObject";
/* Ew */
if (field.Type.TypeName == "Zone" && m_Library == "base")
m_Impl << "(\"Zone\", ";
else
m_Impl << "<" << field.Type.TypeName << ">(";
m_Impl << "oldValue).get());" << std::endl
<< "\t" << "if (!newValue.IsEmpty())" << std::endl
<< "\t\t" << "DependencyGraph::AddDependency(this, ConfigObject::GetObject";
/* Ew */
if (field.Type.TypeName == "Zone" && m_Library == "base")
m_Impl << "(\"Zone\", ";
else
m_Impl << "<" << field.Type.TypeName << ">(";
m_Impl << "newValue).get());" << std::endl;
}

These are DependencyGraph::RemoveDependency(this, /* other config object that's referenced in the configuration of this */), so this is the child, like it is now with the fixed names inside DependencyGraph.

@julianbrost julianbrost merged commit 3642ca3 into master Dec 12, 2024
30 of 47 checks passed
@julianbrost julianbrost deleted the DependencyGraph-parent-child branch December 12, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed core/quality Improve code, libraries, algorithms, inline docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants