Icinga/icingaweb2-module-director

API incorrectly returns modified for command objects and templates with arguments

Closed this issue · 4 comments

Expected Behavior

Creating a command object or template with PUT and pushing the same object or template with POST should return in status code 304 (unmodified) as documented.

Current Behavior

API returns 200 upon object / template creation (PUT) but also 200 on update (POST) with the same object data and creates a modified activity in the web ui.

Possible Solution

Sorry, don't know.

Steps to Reproduce (for bugs)

Create new command object providing arguments parameter:

curl -v -X PUT -u "user:pass" -H "Accept: application/json" https://icinga.example.com/director/command -d '{"object_name": "testcmd", "object_type": "object", "methods_execute": "PluginCheck", "command": "cmd.sh", "arguments": { "--arg": "val" }}'
...
< HTTP/1.1 201 Created
...

Now update the object using the same data:

curl -v -X POST -u "user:pass" -H "Accept: application/json" https://icinga.example.com/icingaweb2/director/command?name=testcmd -d '{"object_name": "testcmd", "object_type": "object", "methods_execute": "PluginCheck", "command": "cmd.sh", "arguments": { "--arg": "val" }}'
...
< HTTP/1.1 200 OK
...

Status code 200 is returned and in the web UI a new activity is created showing that command testcmd was modified but without a diff. The exact same happens, when using template as object type.

Note that, when omitting arguments parameter completely in both API requests, POST request correctly returns 304.

This effectively breaks the usage of Ansible Collection for Icinga Director.

Your Environment

  • Director version (System - About): 1.10.2
  • Icinga Web 2 version and modules (System - About): 2.11.2
  • Icinga 2 version (icinga2 --version): 2.13.6
  • Operating System and version: Debian 11 (Bullseye)
  • Webserver, PHP versions: NGINX v1.18.0, PHP 7.4.33

This also happens over the Director GUI, if you just store a command object, without changing something, you will see changes in the activity log, but without a Diff.
If you deploy the changes, the Deployment ID will remain the same.

This breaks our Puppet workflow over the API

any chances to classify this as bug?
I can't identify the real changes in the activity log, because of the command objects.

We have exactly the same issue. Additionally we have found out that the notification endpoint has also this issue.

Thanks for reporting this. Could have been reproduced and has now been fixed.