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

[dev.icinga.com #10561] "remove-comment" action does not support filters #3620

Closed
icinga-migration opened this issue Nov 7, 2015 · 5 comments
Labels
area/api REST API blocker Blocks a release or needs immediate attention bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/10561

Created by gbeutner on 2015-11-07 11:24:29 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2015-11-08 13:24:06 +00:00)
Target Version: 2.4.0
Last Update: 2015-11-08 13:24:06 +00:00 (in Redmine)

Icinga Version: 2.4.0
Backport?: No
Include in Changelog: 0

Why is there a separate "name" attribute instead of just using the filter mechanism we"re using for virtually all other actions?

Changesets

2015-11-08 13:22:10 +00:00 by mfriedrich 1d2606c

Add filter targets for remove-{comment,downtime} actions

Drop remove-all-{comments,downtimes}. This is provided
by using host and service filters.

fixes #10561

2015-11-10 15:13:14 +00:00 by mfriedrich f5da37b

Remove obsolete checks from API actions

refs #10561
@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-11-07 11:25:44 +00:00

In fact, why is there a "remove-all-comments" action?

(Same problem for downtimes.)

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-07 15:09:49 +00:00

  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Priority changed from Normal to High

That"s true, I thought about the same thing yesterday night. I"ll look into that on the weekend :)

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-08 11:58:46 +00:00

The problem is primarily that the comment/downtime actions take place on a Checkable object where we do not know about the downtime name being removed (no filter would then mean remove all downtimes for the matched checkable object). That change is rather trivial.

Changing the registered filter types unveils a different problem - GetFilterTargets does properly filter for "downtime.name" which yields to an empty result set.

michi@mbmif ~ $ curl -k -s -u root:icinga -H "Accept: application/json" -X POST "https://localhost:5665/v1/actions/remove-downtime?filter=match("*ping4*", downtime.name)&type=Downtime"
{"results":[]}

https://localhost:5665/v1/objects/downtimes?filter=match("i-\*", downtime.name) returns an empty result while having the downtime with the following attributes:

{
"results": [
{
"attrs": {
"__name": "i-42866686!ping4!mbmif.local-1446979168-5",
"active": true,
"author": "icingaadmin",
"comment": "IPv4 network maintenance",
"config_owner": "",
"duration": 1000,
"end_time": 1446990132,
"entry_time": 1446979168.34496,
"fixed": false,
"ha_mode": 0,
"host_name": "i-42866686",
"legacy_id": 1,
"name": "mbmif.local-1446979168-5",
"original_attributes": null,
"package": "_api",
"paused": false,
"scheduled_by": "",
"service_name": "ping4",
"start_time": 1446989132,
"templates": [
"mbmif.local-1446979168-5"
],
"trigger_time": 0,
"triggered_by": "",
"triggers": [ ],
"type": "Downtime",
"version": 1446979168.344005,
"was_cancelled": false,
"zone": ""
},
"joins": { },
"meta": { },
"name": "i-42866686!ping4!mbmif.local-1446979168-5",
"type": "Downtime"
},

I could think of a problem passing the ! inside the matching string to the filter which results in a parsing error, or something like that.

I"ve pushed my changes to a feature branch for now.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-08 13:21:54 +00:00

Use simple filters for removing a single downtime or comment:

?downtime=...
?comment=...

Using advanced filters requires a type, being Host, Service and Downtime/Comment. That way you can

  1. filter for comment/downtime name globally
  2. remove all comments/downtimes for matched host or service object filters

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-08 13:24:06 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 1d2606c.

@icinga-migration icinga-migration added blocker Blocks a release or needs immediate attention bug Something isn't working area/api REST API labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.4.0 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api REST API blocker Blocks a release or needs immediate attention bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant