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

db: Cleanup parent/child relations in matching models #1055

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

nilmerg
Copy link
Member

@nilmerg nilmerg commented Sep 16, 2024

The previous relations didn't work as expected.
Now, filtering with child.host.name or
parent.service.name works fine.

@nilmerg nilmerg self-assigned this Sep 16, 2024
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Sep 16, 2024
@nilmerg nilmerg force-pushed the working-parent-child-relations branch from 17ddf17 to de067be Compare September 17, 2024 08:16
The previous relations didn't work as expected.
Now, filtering with `child.host.name` or
`parent.service.name` works fine.
@nilmerg nilmerg force-pushed the working-parent-child-relations branch from 9e386bd to b5a4caa Compare September 17, 2024 09:17
@nilmerg nilmerg marked this pull request as ready for review September 17, 2024 09:21
Copy link
Contributor

@sukhwinder33445 sukhwinder33445 left a comment

Choose a reason for hiding this comment

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

Test:

I have used the example configuration but reduced the number of objects (loop range).

Tested this PR with the filter icingadb/hosts?parent.host.name=big-switch-server-0.

Expected behavior:

No result, as there is no child existing with this host as parent.

Actual behavior:

One host big-switch-server-0 (self) as result. // There are services that have this host as a parent

The sql query:

(icingadb/hosts?parent.host.name=big-switch-server-0&format=sql)

...
WHERE host.id IN ((SELECT sub_host_to_from_host.id AS sub_host_to_from_host_id
                   FROM host sub_host
                            INNER JOIN dependency_node sub_host_dependency_node # here we have 1:n (host : dependency_node) relation
                                       ON sub_host_dependency_node.host_id = sub_host.id
                            INNER JOIN dependency_edge sub_host_to
                                       ON sub_host_to.to_node_id = sub_host_dependency_node.id
                            INNER JOIN dependency_node sub_host_to_from
                                       ON sub_host_to_from.id = sub_host_to.from_node_id
                            LEFT JOIN host sub_host_to_from_host ON sub_host_to_from_host.id = sub_host_to_from.host_id
                   WHERE sub_host.name = 'big-switch-server-0'))
ORDER BY host.display_name
LIMIT 25;

The column dependency_node.host_id is not unique and there are several identical entries in case services exist for this host. This leads to a ‘1:n’ relationship, which leads to false positive results.
Adding a service filter in the case of a host solves this problem.

@nilmerg nilmerg merged commit e54d136 into dependencies Sep 24, 2024
1 check passed
@nilmerg nilmerg deleted the working-parent-child-relations branch September 24, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants