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

Flexible id tags #133

Merged
merged 3 commits into from
Nov 30, 2023
Merged

Flexible id tags #133

merged 3 commits into from
Nov 30, 2023

Conversation

sukhwinder33445
Copy link
Contributor

@sukhwinder33445 sukhwinder33445 commented Oct 6, 2023

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Oct 6, 2023
@sukhwinder33445 sukhwinder33445 force-pushed the manage-flexible-tag-id branch 2 times, most recently from bdaa5a6 to 204adf5 Compare October 9, 2023 08:18
@yhabteab
Copy link
Member

yhabteab commented Oct 9, 2023

Having this custom tags without the service tag being defined:
Bildschirmfoto 2023-10-09 um 12 36 41

Web renders these entries everywhere as follows:
Bildschirmfoto 2023-10-09 um 12 39 39

Note: It's a host object not service. Sometimes it uses the comment tag as a service name and sometimes not.

@yhabteab
Copy link
Member

yhabteab commented Oct 9, 2023

Bildschirmfoto 2023-10-09 um 14 21 48

@sukhwinder33445 sukhwinder33445 marked this pull request as draft October 20, 2023 10:03
@sukhwinder33445 sukhwinder33445 force-pushed the manage-flexible-tag-id branch 4 times, most recently from 62256b1 to 19b5cc8 Compare October 23, 2023 10:16
@sukhwinder33445 sukhwinder33445 marked this pull request as ready for review October 23, 2023 11:50
@sukhwinder33445 sukhwinder33445 force-pushed the manage-flexible-tag-id branch 5 times, most recently from e6cf802 to 5b87eaf Compare October 24, 2023 14:43
@julianbrost
Copy link
Collaborator

I wanted to give this a try, but I only got exceptions on the event and incident detail pages.

Event detail:

SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "event"
LINE 1: ...d_tag.object_id WHERE sub_object_id_tag_object.id = event.id
^

#0 /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Connection.php(402): PDOStatement->execute()
#1 /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Connection.php(418): ipl\Sql\Connection->prepexec()
#2 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/Query.php(699): ipl\Sql\Connection->select()
#3 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(142): ipl\Orm\Query->yieldResults()
#4 [internal function]: ipl\Orm\ResultSet->yieldTraversable()
#5 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(122): Generator->valid()
#6 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(114): ipl\Orm\ResultSet->advance()
#7 /usr/share/icingaweb2/modules/notifications/library/Notifications/Model/Objects.php(69): ipl\Orm\ResultSet->rewind()
#8 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentListItem.php(51): Icinga\Module\Notifications\Model\Objects->getName()
#9 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(111): Icinga\Module\Notifications\Widget\ItemList\IncidentListItem->assembleTitle()
#10 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentListItem.php(71): Icinga\Module\Notifications\Common\BaseListItem->createTitle()
#11 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(84): Icinga\Module\Notifications\Widget\ItemList\IncidentListItem->assembleHeader()
#12 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentListItem.php(103): Icinga\Module\Notifications\Common\BaseListItem->createHeader()
#13 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(93): Icinga\Module\Notifications\Widget\ItemList\IncidentListItem->assembleMain()
#14 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(129): Icinga\Module\Notifications\Common\BaseListItem->createMain()
#15 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(344): Icinga\Module\Notifications\Common\BaseListItem->assemble()
#16 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(566): ipl\Html\HtmlDocument->ensureAssembled()
#17 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#18 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#19 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#20 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#21 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#22 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#23 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#24 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#25 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#26 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#27 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#28 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#29 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#30 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\HtmlDocument->renderUnwrapped()
#31 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/ViewRenderer.php(56): ipl\Html\HtmlDocument->render()
#32 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(970): ipl\Web\Compat\ViewRenderer->render()
#33 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#34 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#35 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch()
#36 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
#37 /usr/share/icingaweb2/library/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
#38 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#39 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#40 {main}

Incident detail:

SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "sub_incident_history"
LINE 1: ...tag.object_id WHERE sub_object_id_tag_object.id = sub_incide...
^

#0 /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Connection.php(402): PDOStatement->execute()
#1 /usr/share/icinga-php/ipl/vendor/ipl/sql/src/Connection.php(418): ipl\Sql\Connection->prepexec()
#2 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/Query.php(699): ipl\Sql\Connection->select()
#3 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(142): ipl\Orm\Query->yieldResults()
#4 [internal function]: ipl\Orm\ResultSet->yieldTraversable()
#5 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(122): Generator->valid()
#6 /usr/share/icinga-php/ipl/vendor/ipl/orm/src/ResultSet.php(114): ipl\Orm\ResultSet->advance()
#7 /usr/share/icingaweb2/modules/notifications/library/Notifications/Model/Objects.php(69): ipl\Orm\ResultSet->rewind()
#8 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php(59): Icinga\Module\Notifications\Model\Objects->getName()
#9 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(111): Icinga\Module\Notifications\Widget\ItemList\IncidentHistoryListItem->assembleTitle()
#10 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php(75): Icinga\Module\Notifications\Common\BaseListItem->createTitle()
#11 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(84): Icinga\Module\Notifications\Widget\ItemList\IncidentHistoryListItem->assembleHeader()
#12 /usr/share/icingaweb2/modules/notifications/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php(145): Icinga\Module\Notifications\Common\BaseListItem->createHeader()
#13 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(93): Icinga\Module\Notifications\Widget\ItemList\IncidentHistoryListItem->assembleMain()
#14 /usr/share/icingaweb2/modules/notifications/library/Notifications/Common/BaseListItem.php(129): Icinga\Module\Notifications\Common\BaseListItem->createMain()
#15 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(344): Icinga\Module\Notifications\Common\BaseListItem->assemble()
#16 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(566): ipl\Html\HtmlDocument->ensureAssembled()
#17 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#18 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#19 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#20 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#21 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#22 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#23 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#24 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#25 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#26 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(297): ipl\Html\HtmlDocument->renderUnwrapped()
#27 /usr/share/icinga-php/ipl/vendor/ipl/html/src/BaseHtmlElement.php(365): ipl\Html\BaseHtmlElement->renderContent()
#28 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\BaseHtmlElement->renderUnwrapped()
#29 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(390): ipl\Html\HtmlDocument->render()
#30 /usr/share/icinga-php/ipl/vendor/ipl/html/src/HtmlDocument.php(568): ipl\Html\HtmlDocument->renderUnwrapped()
#31 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/ViewRenderer.php(56): ipl\Html\HtmlDocument->render()
#32 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(970): ipl\Web\Compat\ViewRenderer->render()
#33 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#34 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#35 /usr/share/icingaweb2/library/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch()
#36 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
#37 /usr/share/icingaweb2/library/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
#38 /usr/share/icingaweb2/library/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
#39 /usr/share/icingaweb2/public/index.php(4): require_once(String)
#40 {main}

Tried with this PR as is as well as rebased onto main in both the icinga/icingaweb2:2.12.0 and icinga/icingaweb2:main (however in an older version, as the current image doesn't even start) and all got those exceptions.

For the parts that I could try, the looks are more, let's say functional:

Event List
Incident List

That should probably receive some nicer styling, however, I don't decide if this is part of the scope of this PR.

@sukhwinder33445
Copy link
Contributor Author

sukhwinder33445 commented Oct 26, 2023

Please pull icinga-php-library's snapshot/nightly, there was a bug in ipl/orm.
The style will be fixed later in other PR.

Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

Adding new patterns to the phpstan baseline is already not a thing I'd accept, but some of them seem to relate to actual bugs. Please have a look and avoid adding stuff to the baseline.

Copy link
Member

@nilmerg nilmerg left a comment

Choose a reason for hiding this comment

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

I approve this, because none of the issues is a deal breaker. To get this done before my vacation, I accept these limitations. Though, they should be tackled later on.


$relations->belongsTo('source', Source::class)->setJoinType('LEFT');
}

public function getName(): ValidHtml
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 subject to change in #132. If there's a need to render a more complex name, it involves changing what's a link and what's not. Hence the hook will be triggered way before this method is being called. So it should be sufficient to return a string here.

$relation = $isIdTag ? 'object.tag' : 'object.extra_tag';
$tagName = $tag->tag;

yield $relation . '.' . $tagName => $tagName;
Copy link
Member

Choose a reason for hiding this comment

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

This should render the label as it's done after the filter has been enriched. i.e. Currently only host is shown. By completing the filter, it changes to Object host. It should be Object host to begin with. Though, I'd rather drop the Object prefix and just capitalize the tag name. Anyway, my main point is, it should not be shown differently in the suggestion list than it's shown after a condition is complete.

/** @var Query $objectIdTagQuery */
$objectIdTagQuery = $this->object_id_tag;
/** @var ObjectIdTag $id_tag */
foreach ($objectIdTagQuery as $id_tag) {
Copy link
Member

Choose a reason for hiding this comment

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

This leads to a separate query for tags for each list item. (If this method is called by a list item)

That's rather in-effective and should be avoided. The plan here should be to join the tags in the base query already, group it and aggregate the tag names and values in two separate columns. They can then be split and combined by php, which is still better than issuing multiple additional queries.

@nilmerg nilmerg merged commit 8a7c2e8 into main Nov 30, 2023
@nilmerg nilmerg deleted the manage-flexible-tag-id branch November 30, 2023 14:17
@nilmerg nilmerg added this to the Preview #1 milestone Nov 30, 2023
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.

4 participants