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 #11065] Deleting an object via API does not disable it in DB IDO #3889

Closed
icinga-migration opened this issue Feb 1, 2016 · 5 comments

Comments

@icinga-migration
Copy link
Member

@icinga-migration icinga-migration commented Feb 1, 2016

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

Created by mfriedrich on 2016-02-01 17:47:25 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2016-02-05 11:37:58 +00:00)
Target Version: 2.4.2
Last Update: 2016-02-23 09:58:45 +00:00 (in Redmine)

Icinga Version: v2.4.1-158-ge6a972f
Backport?: Already backported
Include in Changelog: 1

michi@mbmif ~/coding/icinga $ curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/example.localdomain' \
> -d '{ "templates": [ "generic-host" ], "attrs": { "address": "192.168.1.1", "check_command": "hostalive", "vars.os" : "Linux" } }' \
> | python -m json.tool
{
    "results": [
        {
            "code": 200.0,
            "status": "Object was created"
        }
    ]
}
michi@mbmif ~/coding/icinga $ curl -k -s -u root:icinga -H 'Accept: application/json' -X DELETE 'https://localhost:5665/v1/objects/hosts/example.localdomain?cascade=1'
{"results":[{"code":200.0,"name":"example.localdomain","status":"Object was deleted.","type":"Host"}]}michi@mbmif ~/coding/icinga $

MariaDB [icinga]> select * from icinga_objects where name1 like '%domain%'
    -> ;
+-----------+-------------+---------------+---------------------+-------+-----------+
| object_id | instance_id | objecttype_id | name1               | name2 | is_active |
+-----------+-------------+---------------+---------------------+-------+-----------+
|       263 |           1 |             1 | example.localdomain | NULL  |         1 |
|       264 |           1 |             2 | example.localdomain | ping4 |         1 |
|       265 |           1 |             2 | example.localdomain | ssh   |         1 |
+-----------+-------------+---------------+---------------------+-------+-----------+
3 rows in set (0.00 sec)

Changesets

2016-02-05 11:37:00 +00:00 by mfriedrich 4049cc0

Fix: Deleting an object via API does not disable it in DB IDO

fixes #11065

2016-02-23 08:43:41 +00:00 by mfriedrich 7cbe1c4

Fix: Deleting an object via API does not disable it in DB IDO

fixes #11065

Relations:

@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Feb 4, 2016

Updated by mfriedrich on 2016-02-04 15:22:29 +00:00

  • Priority changed from Normal to High
@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Feb 4, 2016

Updated by mfriedrich on 2016-02-04 16:13:13 +00:00

  • Relates set to 10891
@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Feb 5, 2016

Updated by mfriedrich on 2016-02-05 11:36:29 +00:00

Found it. When ensuring to remove duplicated config updates we changed the DeactivateObject condition. When an object gets deleted we need to ensure that it is deactivated inside the database. It may happen that for some reason the dbActive flag is already set to false (was not enabled before) which will then cause the condition to fail and the object remains active.

michi@mbmif ~ $ curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/example.localdomain' -d '{ "templates": [ "generic-host" ], "attrs": { "address": "192.168.1.1", "check_command": "hostalive", "vars.os" : "Linux" } }' | python -m json.tool
{
    "results": [
        {
            "code": 200.0,
            "status": "Object was created"
        }
    ]
}
michi@mbmif ~ $ curl -k -s -u root:icinga -H 'Accept: application/json' -X DELETE 'https://localhost:5665/v1/objects/hosts/example.localdomain?cascade=1'
{"results":[{"code":200.0,"name":"example.localdomain","status":"Object was deleted.","type":"Host"}]}michi@mbmif ~ $

MariaDB [icinga]>  select * from icinga_objects where name1 like '%domain%';
+-----------+-------------+---------------+---------------------+-------+-----------+
| object_id | instance_id | objecttype_id | name1               | name2 | is_active |
+-----------+-------------+---------------+---------------------+-------+-----------+
|       263 |           1 |             1 | example.localdomain | NULL  |         1 |
|       264 |           1 |             2 | example.localdomain | ping4 |         1 |
|       265 |           1 |             2 | example.localdomain | ssh   |         1 |
+-----------+-------------+---------------+---------------------+-------+-----------+
3 rows in set (0.00 sec)

MariaDB [icinga]>  select * from icinga_objects where name1 like '%domain%';
+-----------+-------------+---------------+---------------------+-------+-----------+
| object_id | instance_id | objecttype_id | name1               | name2 | is_active |
+-----------+-------------+---------------+---------------------+-------+-----------+
|       263 |           1 |             1 | example.localdomain | NULL  |         0 |
|       264 |           1 |             2 | example.localdomain | ping4 |         0 |
|       265 |           1 |             2 | example.localdomain | ssh   |         0 |
+-----------+-------------+---------------+---------------------+-------+-----------+
3 rows in set (0.00 sec)
@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Feb 5, 2016

Updated by mfriedrich on 2016-02-05 11:37:58 +00:00

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

Applied in changeset 4049cc0.

@icinga-migration
Copy link
Member Author

@icinga-migration icinga-migration commented Feb 23, 2016

Updated by gbeutner on 2016-02-23 09:58:45 +00:00

  • Backport? changed from Not yet backported to Already backported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.