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

Sort config types by their load dependencies once #10148

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yhabteab
Copy link
Member

@yhabteab yhabteab commented Sep 10, 2024

This PR is basically the same as #10003, but since @Al2Klimov is out for this week, we need to get it done. So I've cherry-picked the commits from there and added some additional commits to address the requested changes in that PR.

closes #10003

@cla-bot cla-bot bot added the cla/signed label Sep 10, 2024
@icinga-probot icinga-probot bot added the core/quality Improve code, libraries, algorithms, inline docs label Sep 10, 2024
@yhabteab yhabteab self-assigned this Sep 10, 2024
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from 8a2ee5a to f78108d Compare September 10, 2024 09:19
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.

Compared to #10003, this PR has no cycle detection (at least I believe the purpose of some of the code might be cycle detection, it's not entirely clear though: #10003 (comment)). When I intentionally introduced a dependency in the *.ti files, nothing in mkclass stopped me from doing so and all I got was a not very helpful error message in a test (see inline comment). So some more explicit "this failed due to a cycle" error reporting/VERIFY() might be a good idea.

test/base-type.cpp Outdated Show resolved Hide resolved
lib/base/type.cpp Outdated Show resolved Hide resolved
lib/base/type.cpp Outdated Show resolved Hide resolved
lib/base/type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from f78108d to 7c56ec3 Compare September 11, 2024 16:25
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch 3 times, most recently from bfcfe80 to e019556 Compare September 11, 2024 17:04
lib/base/type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
lib/base/type.cpp Show resolved Hide resolved
lib/base/type.cpp Outdated Show resolved Hide resolved
test/base-type.cpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from e019556 to e011597 Compare September 12, 2024 10:56
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch 2 times, most recently from b21a41f to 2c308dd Compare September 12, 2024 13:50
@yhabteab yhabteab requested review from julianbrost and removed request for julianbrost September 12, 2024 13:50
test/CMakeLists.txt Outdated Show resolved Hide resolved
lib/base/type.hpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from 2c308dd to 9442803 Compare September 12, 2024 15:05
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.

Looks fine and should do the job, I just don't want to do a quick approve + merge right before leaving for vacation and another pair of eyes shouldn't hurt. But I'd say you can optimistically adapt #10000 already.

I'm not 100% happy regarding the needs for the test changes including the CMakeLists changes, but that's probably what happens when relying on linker/loader magic for the type registration (the alternative would be to perform an extra self check within the implementation, so that it's checked every single time, but that's also not too nice).

lib/base/type.cpp Outdated Show resolved Hide resolved
lib/base/type.cpp Outdated Show resolved Hide resolved
Comment on lines +67 to +75
// The magic number 12 is the sum of host,service,comment,downtime and endpoint load_after dependencies.
BOOST_CHECK_MESSAGE(totalDependencies >= 12, "total size of load dependency must be at least 12");
BOOST_CHECK_MESSAGE(previousTypes.find(Host::TypeInstance.get()) != previousTypes.end(), "Host type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Service::TypeInstance.get()) != previousTypes.end(), "Service type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Downtime::TypeInstance.get()) != previousTypes.end(), "Downtime type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Comment::TypeInstance.get()) != previousTypes.end(), "Comment type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Notification::TypeInstance.get()) != previousTypes.end(), "Notification type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Zone::TypeInstance.get()) != previousTypes.end(), "Zone type should be in the list");
BOOST_CHECK_MESSAGE(previousTypes.find(Endpoint::TypeInstance.get()) != previousTypes.end(), "Endpoint type should be in the list");
Copy link
Member

Choose a reason for hiding this comment

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

What about just comparing to all types|grep config type? 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

I am looking for config types that have to be always there, and unlike other types they cannot be disabled with cmake build flags like -DICINGA2_WITH_ICINGADB=OFF.

@yhabteab
Copy link
Member Author

Oh! We can't backport this to 2.13.x due to 33e609d.

@Al2Klimov
Copy link
Member

Do you mean "We can't backport this to 2.13.x without 33e609d"?

@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from abb068e to b85fc9f Compare September 20, 2024 10:34
@yhabteab
Copy link
Member Author

Just rebased it!

@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from b85fc9f to cb4fe57 Compare September 20, 2024 13:32
@yhabteab yhabteab force-pushed the enhanced-sort-types-by-load-dependencies branch from cb4fe57 to eb97676 Compare September 20, 2024 14:18
@yhabteab yhabteab requested review from Al2Klimov and removed request for Al2Klimov September 20, 2024 14:18
types/instantiate
types/sort_by_load_after
)

Copy link
Member

Choose a reason for hiding this comment

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

This is fine. 🎩🐶☕🔥🏠

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