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 #9777] Make Comments and Downtime types available as ConfigObject type in the API #3197

Closed
icinga-migration opened this issue Jul 30, 2015 · 33 comments
Labels
area/api REST API blocker Blocks a release or needs immediate attention enhancement New feature or request
Milestone

Comments

@icinga-migration
Copy link

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

Created by gbeutner on 2015-07-30 06:03:10 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2015-10-28 17:00:05 +00:00)
Target Version: 2.4.0
Last Update: 2015-11-12 15:34:38 +00:00 (in Redmine)

Backport?: No
Include in Changelog: 1

That way we wouldn't have to add special cases for these object types in the API.

Changesets

2015-10-28 16:56:29 +00:00 by (unknown) 050c520

Convert Comment/Downtime to config objects

fixes #9777

2015-10-29 07:14:55 +00:00 by (unknown) 0013d26

Build fix for Windows

refs #9777

Relations:

@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-07-30 06:05:18 +00:00

  • Blocked set to 9082

@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-08-15 18:14:35 +00:00

  • Category changed from libicinga to API

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-08-17 08:53:12 +00:00

  • Subject changed from Comments and Downtime types should inherit from DynamicObject to Comments and Downtime types should inherit from ConfigObject

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-04 11:58:17 +00:00

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

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-12 09:08:37 +00:00

  • Relates set to 8897

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-14 12:37:58 +00:00

Apart from the scheduled downtime object DB IDO currently tries to insert additional downtimes, which make little sense.

DELETE FROM icinga\_scheduleddowntime WHERE object\_id = 108;
INSERT INTO icinga\_scheduleddowntime (author\_name, comment\_data, downtime\_type, duration, endpoint\_object\_id, entry\_time, instance\_id, internal\_downtime\_id, is\_fixed, is\_in\_effect, object\_id, was\_started) VALUES ('', '', '1', '0', 96, FROM\_UNIXTIME(1442233761), 1, '0', '0', '0', 108, '0');
INSERT INTO icinga\_scheduleddowntime (author\_name, comment\_data, downtime\_type, duration, endpoint\_object\_id, entry\_time, instance\_id, internal\_downtime\_id, is\_fixed, is\_in\_effect, object\_id, was\_started) VALUES ('', '', '1', '0', 96, FROM\_UNIXTIME(1442233761), 1, '0', '0', '0', 108, '0');
INSERT INTO icinga\_scheduleddowntime (author\_name, comment\_data, downtime\_type, duration, endpoint\_object\_id, entry\_time, instance\_id, internal\_downtime\_id, is\_fixed, is\_in\_effect, object\_id, was\_started) VALUES ('', '', '1', '0', 96, FROM\_UNIXTIME(1442233761), 1, '0', '0', '0', 108, '0');
INSERT INTO icinga\_scheduleddowntime (author\_name, comment\_data, downtime\_type, duration, endpoint\_object\_id, entry\_time, instance\_id, internal\_downtime\_id, is\_fixed, is\_in\_effect, object\_id, scheduled\_end\_time, scheduled\_start\_time, was\_started) VALUES ('icingaadmin', 'Scheduled downtime for backup', '1', '0', 96, FROM\_UNIXTIME(1442233761), 1, '1', '1', '0', 108, FROM\_UNIXTIME(1442278800), FROM\_UNIXTIME(1442275200), '0');
</pre

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-14 12:40:58 +00:00

Ok nvm, I had to delete the state file containing faulty downtimes from previous tests.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-14 12:53:14 +00:00

Ok, found it: While adding downtimes during runtime, they are not persisted on disk. The state file only stores [state] attributes and stores/restores invalid Downtime and Comments.

        [config, protected, required] name(Host) host_name;
        [config, protected] String service_name;
        [config] double entry_time {
                default {{{ return Utility::GetTime(); }}}
        };
        [config, required] String author;
        [config, required] String comment;
        [config] double start_time;
        [config] double end_time;
        [state] double trigger_time;
        [config] bool fixed;
        [config] double duration;
        [state] int triggered_by_legacy_id;
        [state] String triggered_by;
        [config] String scheduled_by;
        [config] Dictionary::Ptr triggers {
                default {{{ return new Dictionary(); }}}
        };
        int legacy_id;
        [state] bool was_cancelled;
        [state] String config_owner;

"name":"mbmif.int.netways.de!load","type":"Service","update":{"acknowledgement":0.0,"acknowledgement_expiry":0.0,"check_attempt":1.0,"comments":{},"downtimes":{"mbmif.int.netways.de-1442234329-0":{"config_owner":"mbmif.int.netways.de!load!backup-downtime","trigger_time":0.0,"triggered_by":"","triggered_by_legacy_id":0.0,"type":"Downtime","was_cancelled":false},"mbmif.int.netways.de-1442234489-0":{"config_owner":"mbmif.int.netways.de!load!backup-downtime","trigger_time":0.0,"triggered_by":"","triggered_by_legacy_id":0.0,"type":"Downtime","was_cancelled":false}},

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-14 12:56:45 +00:00

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

Not sure how we should proceed here further, that depends on the object config sync branch.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-17 12:03:21 +00:00

  • Relates set to 9927

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-09-28 12:57:07 +00:00

  • Relates set to 9960

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-19 09:42:00 +00:00

  • Priority changed from Normal to High

@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-10-22 08:56:16 +00:00

  • Assigned to set to gbeutner

@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-10-27 08:35:57 +00:00

TODO:

  • ignore_on_error
  • Remove comments/downtimes

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-27 11:26:29 +00:00

  • Events
    • IDO Updates
    • Cluster

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-27 11:35:02 +00:00

  • ignore_on_error default value for comment/downtime

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-27 14:45:24 +00:00

  • Cache host/service object for GetCheckable()

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-27 15:08:35 +00:00

TODO

  • Comments
    • Cleanup
    • Remove
  • Events
    • downtime/object was created
    • DB IDO, Event Streams

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-27 16:50:38 +00:00

Changed the code for comments similar to downtimes and tested those changes.

TODO for 28.10.+

  • Events
    • downtime/object was created
    • DB IDO, Event Streams
  • ignore_on_error default value for comment/downtime
  • Cache host/service object for GetCheckable()

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 09:15:56 +00:00

  • Remove* - use pointer instead of name
  • remove host and service name from apievents for Comment and Downtime events

@icinga-migration
Copy link
Author

Updated by gbeutner on 2015-10-28 09:59:25 +00:00

TODO:

  • triggers -> Array
  • test triggers

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 14:05:29 +00:00

  • Remove MessageOrigin from On{Comment,Downtime}{Added,Removed}

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 14:15:06 +00:00

  • Figure out whether we should remove triggered_by_legacy_id

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 15:19:01 +00:00

Changing the parameter for Remove* from String to a pointer does not make sense.

Done

  • Remove MessageOrigin from On{Comment,Downtime}{Added,Removed}
  • remove host and service name from apievents for Comment and Downtime events
  • Events
    • downtime/object was created
    • DB IDO, Event Streams
  • Cache host/service object for GetCheckable()
  • Fixed OnAllConfigLoaded exceptions with ignore_on_error
  • "ignore_on_error" can be passed using /v1/objects/{downtimes,comments}, defaults to false

TODO

  • Figure out whether we should remove triggered_by_legacy_id
  • ignore_on_error default value for comment/downtime
  • Test downtime triggers

Tests

$ curl -s -k -u 'root:icinga' -X PUT 'https://localhost:5665/v1/objects/comments/mbmif.int.netways.de!bla' -d '{ "attrs": { "author": "michi", "text": "bumsti" } }'
{"results":[{"code":200.0,"status":"Object was created"}]}

$ curl -s -k -u 'root:icinga' -X PUT 'https://localhost:5665/v1/objects/downtimes/mbmif.int.netways.de!bla' -d '{ "attrs": { "author": "michi", "comment": "bumsti" } }'
{"error":500.0,"status":"Object could not be created."}

$ curl -s -k -u 'root:icinga' -X PUT 'https://localhost:5665/v1/objects/downtimes/mbmif.int.netways.de!bla?ignore_on_error=1' -d '{ "attrs": { "author": "michi", "comment": "bumsti" } }'
{"results":[{"code":200.0,"status":"Object was not created but 'ignore_on_error' was set to true"}]}

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 15:19:14 +00:00

  • Status changed from New to Assigned
  • Done % changed from 0 to 90

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 15:19:46 +00:00

  • Assigned to changed from gbeutner to mfriedrich

Remaining tasks for tomorrow.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 15:55:48 +00:00

Downtimes are triggered

  1. a service in OK state, downtime scheduled, then !OK state is passed
  2. immediately triggered if the state is !OK

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 16:26:31 +00:00

  • Subject changed from Comments and Downtime types should inherit from ConfigObject to Make Comments and Downtime types available as ConfigObject type in the API

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 16:48:21 +00:00

Done

  • Figure out whether we should remove triggered_by_legacy_id

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 16:49:51 +00:00

I'm not sure if we really need a default value for ignore_on_error anymore since we are now passing that value via the API create object method. The inner defaults inside Add* and Remove* are set to true where they belong to.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-10-28 16:51:58 +00:00

Further TODOs:

  • Documentation
    • Object Types: Comments, Downtimes and their attributes
    • API Objects: Comment and Downtime type

@icinga-migration
Copy link
Author

Updated by Anonymous on 2015-10-28 17:00:05 +00:00

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

Applied in changeset 050c520.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-12 15:34:38 +00:00

  • Backport? changed from TBD to No

@icinga-migration icinga-migration added blocker Blocks a release or needs immediate attention enhancement New feature or request 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 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant