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

Icinga DB: dump the correct icinga:config:endpoint#zone_id #8706

Merged
merged 1 commit into from
Apr 26, 2021

Conversation

Al2Klimov
Copy link
Member

No description provided.

@Al2Klimov Al2Klimov added bug Something isn't working area/icingadb New backend labels Mar 26, 2021
@Al2Klimov Al2Klimov self-assigned this Mar 26, 2021
@icinga-probot icinga-probot bot added this to the 2.13.0 milestone Mar 26, 2021
@Al2Klimov
Copy link
Member Author

Before

$ redis-cli hgetall icinga:config:endpoint
1) "5ffd3470e558666b25ccd505c329faa0f1932596"
2) "{\"environment_id\":\"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\"name\":\"Alexanders-MacBook-Pro.local\",\"name_checksum\":\"aa0db2d5375043173db4a7b4c95a919a056c8355\"}"
$

After

$ redis-cli hgetall icinga:config:endpoint
1) "5ffd3470e558666b25ccd505c329faa0f1932596"
2) "{\"environment_id\":\"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\"name\":\"Alexanders-MacBook-Pro.local\",\"name_checksum\":\"aa0db2d5375043173db4a7b4c95a919a056c8355\",\"zone\":\"Alexanders-MacBook-Pro.local\",\"zone_id\":\"5ffd3470e558666b25ccd505c329faa0f1932596\"}"
$

@Al2Klimov Al2Klimov removed their assignment Mar 26, 2021
@Al2Klimov Al2Klimov marked this pull request as ready for review March 26, 2021 12:55
@Al2Klimov Al2Klimov requested a review from julianbrost March 26, 2021 12:55
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.

This just looks really error-prone.

Is there any situation where it would make sense to actually set the zone attribute of an endpoint object to something else than the zone of which the endpoint is a member? Or in other words, can we make ConfigObject::GetZone() virtual (or set ConfigObject::m_Zone from Endpoint) instead?

I've skipped through all uses of GetZone() and the only other ones I could find that operate on the static type ConfigObject are the following:

So it should be feasible to look over these if changing the behavior of ConfigObject::GetZone() for Endpoint objects would be a problem.

@Al2Klimov
Copy link
Member Author

@lippserd What about zone in zone?

@Al2Klimov Al2Klimov added the needs feedback We'll only proceed once we hear from you again label Apr 12, 2021
@julianbrost
Copy link
Contributor

With file-based config sync this shouldn't be an issue as the config is synced based on the directory it is in. Maybe this could create issues with object-based config sync for API-created objects? I.e. if you'd add an Endpoint via the API, it would then be synced down to this endpoint where it yields an error as this already exists (as it has to be configured for the cluster to even connect)?

@lippserd
Copy link
Member

@lippserd What about zone in zone?

I'm not entirely sure what the question is, but since configuring zone(s) in zone(s) is not an issue, Icinga 2 should dump the actual zone of the object, not the zone in which it was defined.

Does that answer your question?

@lippserd lippserd assigned Al2Klimov and unassigned lippserd Apr 15, 2021
@Al2Klimov
Copy link
Member Author

My question: can endpoint objects also be inside zones, i.e. "non-locally"?

@Al2Klimov Al2Klimov assigned lippserd and unassigned Al2Klimov Apr 16, 2021
@lippserd
Copy link
Member

My question: can endpoint objects also be inside zones, i.e. "non-locally"?

Yes.

@Al2Klimov
Copy link
Member Author

So the Endpoint's Zone getter is actually used to determine the Zone where the Endpoint is defined.

@julianbrost So we shall not override the getter's semantics.

@Al2Klimov Al2Klimov requested a review from julianbrost April 16, 2021 08:56
@julianbrost
Copy link
Contributor

Ok, then we probably need a relationship with two different zones for each endpoint. I think we should then also make this explicit everywhere.

With the current state of this PR, zone_id would refer to the zone containing the object for all objects except endpoints. For these it would be the zone the endpoint is actually a member of. This would be inconsistent.

Why is the zone information that's currently dumped wrong in the first place? After all it's a zone that has a relationship to the endpoint and it's the same information that's currently returned when querying endpoint objects using the API:

$ curl -skSu root:icinga -H 'Accept: application/json' 'https://localhost:5665/v1/objects/endpoints/master-1?attrs=zone'
{"results":[{"attrs":{"zone":""},"joins":{},"meta":{},"name":"master-1","type":"Endpoint"}]}
$ curl -skSu root:icinga -H 'Accept: application/json' 'https://localhost:5665/v1/objects/endpoints/agent-1?attrs=zone'
{"results":[{"attrs":{"zone":"master"},"joins":{},"meta":{},"name":"agent-1","type":"Endpoint"}]}

I'd rather add the zone membership information as additional attributes, maybe called something like member_of_zone (I don't like this name but I have to suggest something).

In the long run (probably not as part of this PR), I'd also rename Endpoint::GetZone() accordingly so that it no longer shadows ConfigObject::GetZone().

@Al2Klimov
Copy link
Member Author

@lippserd Any strong opinion on this?

@lippserd
Copy link
Member

It should be the zone where the object is a member of.

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.

Ok, then we're switching from the value of the zone attribute as known to Icinga to something the user hopefully expects the zone of an object to be. This should then be documented at some point (probably in some form of schema documentation, but this would fit better into the Icinga DB repo).

@Al2Klimov Al2Klimov deleted the bugfix/icingadb-endpoint-zone branch May 26, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/icingadb New backend bug Something isn't working needs feedback We'll only proceed once we hear from you again
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants