weixin_39690097 2020-11-29 10:24
浏览 0

[dev.icinga.com #11396] inconsistent API /v1/objects/* response for PUT requests

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

Created by danvaida on 2016-03-16 12:39:04 +00:00

Assignee: mfriedrich Status: Resolved (closed on 2016-05-09 13:10:03 +00:00) Target Version: 2.4.8 Last Update: 2016-05-11 07:38:31 +00:00 (in Redmine)

Icinga Version: 2.4.3
Backport?: Not yet backported
Include in Changelog: 1
icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: v2.4.3)

Copyright (c) 2012-2016 Icinga Development Team (https://www.icinga.org/)
License GPLv2+: GNU GPL version 2 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Application information:
  Installation root: /usr
  Sysconf directory: /etc
  Run directory: /run
  Local state directory: /var
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid

System information:
  Platform: CentOS Linux
  Platform version: 7 (Core)
  Kernel: Linux
  Kernel version: 3.10.0-229.14.1.el7.x86_64
  Architecture: x86_64

While calling the API for 3 operations, I am expecting something different. For example:

curl -s --cacert /etc/icinga2/pki/ca.crt --cert /etc/icinga2/pki/icinga2-master.crt --key /etc/icinga2/pki/icinga2-master.key -H 'Accept: application/json' -X PUT 'https://icinga2-master:5665/v1/objects/users/dvaida' -d '{ "attrs": { "email": "me.com" } }' | python -m json.tool
{
    "results": [
        {
            "code": 200.0,
            "status": "Object was created"
        }
    ]
}

curl -s --cacert /etc/icinga2/pki/ca.crt --cert /etc/icinga2/pki/icinga2-master.crt --key /etc/icinga2/pki/icinga2-master.key -H 'Accept: application/json' -X PUT 'https://icinga2-master:5665/v1/objects/users/dvaida' -d '{ "attrs": { "email": "me.com" } }'
Error: Configuration file '/var/lib/icinga2/api/packages/_api/icinga2-master-1457440041-1/conf.d/users/dvaida.conf' already exists.

It'd be nice to get a 503 maybe (like in the case of other requests for already existing objects).

curl -s --cacert /etc/icinga2/pki/ca.crt --cert /etc/icinga2/pki/icinga2-master.crt --key /etc/icinga2/pki/icinga2-master.key -H 'Accept: application/json' -X DELETE 'https://icinga2-master:5665/v1/objects/users/dvaida' | python -m json.tool
{
    "results": [
        {
            "code": 200.0,
            "name": "dvaida",
            "status": "Object was deleted.",
            "type": "User"
        }
    ]
}

Also, I can't really tell if the object was indeed updated or not as it's always the same response:

curl -s --cacert /etc/icinga2/pki/ca.crt --cert /etc/icinga2/pki/icinga2-master.crt --key /etc/icinga2/pki/icinga2-master.key -H 'Accept: application/json' -X POST 'https://icinga2-master:5665/v1/objects/users/dvaida' -d '{ "attrs": { "email": "me.com" } }' | python -m json.tool
{
    "results": [
        {
            "code": 200.0,
            "name": "dvaida",
            "status": "Attributes updated.",
            "type": "User"
        }
    ]
}

Attachments

Changesets

2016-05-09 13:08:35 +00:00 by mfriedrich 8a65c4a776bf0e7e8215b5ab4f15664c32270e00

API: Fix error message with PUT requests for existing objects

fixes #11396

2016-05-10 11:43:36 +00:00 by mfriedrich 1c6f09f44ee5be43373042c7132e4b3e3fcb357d

API: Fix error message handling for invalid attributes in PUT requests

refs #11396

2016-05-12 09:08:21 +00:00 by mfriedrich 83985f97af89c99efe2631a60b4ee910f960b216

API: Fix error message with PUT requests for existing objects

fixes #11396

2016-05-12 09:09:49 +00:00 by mfriedrich 06f97c87ede7b550069222d8ed74612fc848f38e

API: Fix error message handling for invalid attributes in PUT requests

refs #11396

该提问来源于开源项目:Icinga/icinga2

  • 写回答

9条回答 默认 最新

  • weixin_39690097 2020-11-29 10:24
    关注

    Updated by mfriedrich on 2016-03-18 10:07:03 +00:00

    • Status changed from New to Assigned
    • Assigned to set to jflach

    • Change the PUT request to return a JSON response if an object already exists

    • Discuss whether changes could be highlighted in a better way
    评论

报告相同问题?