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

Dependency: track all relationships via DependencyGraph #8197

Closed

Conversation

Al2Klimov
Copy link
Member

@Al2Klimov Al2Klimov commented Aug 27, 2020

... to ensure dependencies get deleted via cascade=1.

fixes #8180

@Al2Klimov Al2Klimov added bug Something isn't working area/api REST API labels Aug 27, 2020
@Al2Klimov Al2Klimov added this to the 2.13.0 milestone Aug 27, 2020
@Al2Klimov
Copy link
Member Author

Before

After

➜  icinga2 git:(bugfix/deleting-service-cascade-1-dependencies-8180) curl -fksSLu root:icinga -H 'Accept: application/json' -X GET 'https://localhost:5665/v1/objects/dependencies/lolcat2!rofl!mew' -d '{ "pretty": true }'; echo

curl: (22) The requested URL returned error: 404 Not Found

➜  icinga2 git:(bugfix/deleting-service-cascade-1-dependencies-8180) curl -fksSLu root:icinga -H 'Accept: application/json' -X GET 'https://localhost:5665/v1/objects/dependencies/lolcat2!rofl!lolcat' -d '{ "pretty": true }'; echo

curl: (22) The requested URL returned error: 404 Not Found

➜  icinga2 git:(bugfix/deleting-service-cascade-1-dependencies-8180)

@shaikatz
Copy link

Hi, any updates on that? looking forward to seeing that merged.

@Al2Klimov Al2Klimov force-pushed the bugfix/deleting-service-cascade-1-dependencies-8180 branch from b6c2fc6 to 556d4d2 Compare December 14, 2020 14:58
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.

I think there was just a typo (or copy paste mistake) in the old code, see inline comment. Fixing this should suffice, other places use the very same method to track dependencies, see for example comment.ti:

[config, protected, required, navigation(host)] name(Host) host_name {
navigate {{{
return Host::GetByName(GetHostName());
}}}
};
[config, protected, navigation(service)] String service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
DependencyGraph::RemoveDependency(this, service.get());
}
if (!newValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
DependencyGraph::AddDependency(this, service.get());
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
}}}
};

So if there's something wrong in general with how tracking of service dependencies works right now, there are more places where this should be changes. But I think the current way works fine apart from the typo in the tracking code for Dependency.child_service_name.

Note that there is no tracking explicitly specified, this is implicitly generated (there is ObjectImpl<Comment>::TrackHostName in comment-ti.cpp for example).

navigate {{{
return Host::GetByName(GetChildHostName());
}}}
};

[config, navigation(child_service)] String child_service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the root cause for the related issue is that it should say GetChildHostName() here and in line 40.

@icinga-probot icinga-probot bot removed this from the 2.13.0 milestone Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api REST API bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icinga2 API: deleting Service with cascade=1 does not delete its related dependencies
3 participants