-
Notifications
You must be signed in to change notification settings - Fork 21
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
Sync dependencies #889
base: main
Are you sure you want to change the base?
Sync dependencies #889
Conversation
schema/mysql/schema.sql
Outdated
@@ -188,6 +188,8 @@ CREATE TABLE host ( | |||
check_interval int unsigned NOT NULL, | |||
check_retry_interval int unsigned NOT NULL, | |||
|
|||
affected_children int unsigned DEFAULT NULL, |
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.
I'd suggest renaming that column to something like dependency_children
. affected_children
makes it sound like this should be some dynamic value, but it's actually a static config value and whether this number of children actually affected is shown by affects_children
in the state tables. (Same for the service
table and the PostgreSQL schema of course.)
@nilmerg Any objections to such a change as it also affects web?
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.
My only objection is against your reasoning. It's not inside the state table but in the config table and hence one shouldn't assume it being a dynamic value.
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.
I'm just saying that a name that says that it's the total number of checkables that have a dependency on this one better reflects what's stored in the column. With the name affected_children
this feels more like "if the corresponding affects_children
is true, then this is the number, otherwise it's a meaningless value" to me.
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.
It is a meaningless value. We limit it to 1001 after all. Or don't we? This is even more important for Web, actually. :P
What I want to say, at the current stage (with limit) the name always lies, whatever it's called.
If the limit is lifted by now, then total_children
fits most, right?
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.
At the moment, no such limit is implemented. That would have been more of a safeguard against many objects with many children. However, limiting that makes little sense if we need to update the reachability of each child with every state change of the parent anyways (I'm still worried that this might actually cause problems).
0a91368
to
8fdf0a2
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.
So now I have two places things that I suggest to rename in the schema:
affected_children
->total_children
, see Sync dependencies #889 (comment)redundancy_group
->redundancygroup
in all table and column names, see Sync dependencies #889 (comment)
Both affect web, so that should be coordinated. @nilmerg Are you fine with both of these changes? And if so, shall we just update this PR and Icinga/icinga2#10290 and ping you once done?
@@ -1334,6 +1342,61 @@ CREATE TABLE sla_history_downtime ( | |||
INDEX idx_sla_history_downtime_env_downtime_end (environment_id, downtime_end) COMMENT 'Filter for sla history retention' | |||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; | |||
|
|||
CREATE TABLE redundancy_group ( |
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.
I'd rename this table to redundancygroup
(and redundancygroup_state
respectively) for two reasons:
- Consistency with other already existing group tables:
icingadb/schema/mysql/schema.sql
Line 229 in a77498d
CREATE TABLE hostgroup ( icingadb/schema/mysql/schema.sql
Line 395 in a77498d
CREATE TABLE servicegroup ( icingadb/schema/mysql/schema.sql
Line 1027 in a77498d
CREATE TABLE usergroup ( - Makes the following special-casing for the table name unnecessary 1:
icingadb/pkg/icingadb/v1/dependency.go
Lines 16 to 19 in 8fdf0a2
// TableName implements [database.TableNamer]. func (r *Redundancygroup) TableName() string { return "redundancy_group" }
Footnotes
-
I presume that's currently necessary due to the inconsistency between Redis (
icinga:redundancygroup
, i.e. no separator inredundancygroup
) and SQL (redundancy_group
, i.e. with a separator), otherwise the Go type could also be namedRedundancyGroup
. ↩
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.
- otherwise the Go type could also be named
RedundancyGroup
. ↩
No, it cannot! The Redis keys are generated dynamically based on the Go type name and that would result in icinga:redundancy:group
which does not exist in Icinga 2.
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.
"Otherwise" as in "if it actually was icinga:redundancy:group
and redundancy_group
"
schema/mysql/schema.sql
Outdated
CONSTRAINT pk_dependency_node PRIMARY KEY (id), | ||
|
||
UNIQUE INDEX idx_dependency_node_host_service_redundancygroup_id (host_id, service_id, redundancy_group_id), | ||
CONSTRAINT ck_dependency_node_either_checkable_or_redundancy_group_id CHECK (IF(host_id IS NULL, 1, 0) + IF(service_id IS NULL, 1, 0) + IF(redundancy_group_id IS NULL, 1, 0) <= 2) |
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.
That check would also allow host_id
and redundancy_group_id
be set at the same time. Should probably be something more like that:
IF(redundancy_group_id IS NULL, host_id IS NULL AND service_id IS NULL, host_id IS NOT NULL)
I initially asked Johannes about this and both agreed to keep it as it is, as the effort for renaming on the web side is not worth it compared to a one-line solution on the Go side, i.e. implementing the |
I'm totally fine with |
Why is it a typo? |
I would consider it a typo if it was was named "hostgruop" or something like that. In that case, naming new things like this for consistency would be truely insane. However, nothing is misspelled here, it's just a question of convention how things are mapped to SQL identifiers.
Neither was I, so I don't know the exact motivation for the current names, but the general pattern seems to be that tables are named like the corresponding Icinga 2 object types converted to lowercase with sub-tables (like group members) being named with some So for me, that looks perfectly fine as well, that is, considered in isolation,
I mean that might be nice, but do you really expect that we'd go through the pain of renaming many existing tables any time soon just for cosmetic reasons? And were would you stop? "checkcommand" and "customvar" aren't English words either. If you insist on the naming for this individual table, I predict that there will be inconsistencies in both the table names ( In case the PHP class names are that important to you and they are indeed directly tied to the table names, I'd consider relaxing the latter and adding a mechanism similar to that (I really didn't expect that to be such a controversial suggestion...) |
8fdf0a2
to
dd191ef
Compare
Indeed. That's where things went wrong. Icinga 2's class is also camel case. For some reason, someone decided against transforming this to snake case.
There is such a mechanism, but that wasn't implemented for the purpose of having a different naming syntax for class names. I'd have to verify whether this mechanism reliably works this way, where as what you have does already reliably work.
I'm actually somewhat annoyed that this even comes up, half a year after I put up the schema suggestion. |
I don't see that there's anything inherently wrong with that choice.
That's simply something I didn't notice when looking at the schema diff as there's no inconsistency within the diff but only with other parts of the same file. So I actually only noticed the inconsistency when seeing that I expected the suggested change to be trivial and I still believe it would be a bad idea to introduce that inconsistency, but it really doesn't feel like that discussion is worth my time. So if you believe this is actually a good idea, I won't stop you, just be prepared for some "told you so" in the future. |
I'll gladly take that risk :) |
dd191ef
to
2736a9a
Compare
2736a9a
to
277bb7b
Compare
Requires