Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

CLI definition export incorrectly serialises federation upstreams #435

Closed
michaelklishin opened this issue Jun 26, 2020 · 2 comments · Fixed by #436
Closed

CLI definition export incorrectly serialises federation upstreams #435

michaelklishin opened this issue Jun 26, 2020 · 2 comments · Fixed by #436
Assignees
Labels
Milestone

Comments

@michaelklishin
Copy link
Member

michaelklishin commented Jun 26, 2020

"Incorrectly" here means it uses keyword lists instead of maps:

Importing definitions in JSON from a file at "/path/to/defs.plugins.cli.json" ...
Error:
Validation failed

Unrecognised terms [[<<"ack-mode">>,<<"on-confirm">>],
                    [<<"trust-user-id">>,false],
                    [<<"uri">>,<<"amqp://127.0.0.1:5672">>]] in up-1
Key "uri" not found in up-1
 (//federation-upstream/up-1)

This issue is not present with a file produced by the HTTP API.

Discovered while working on rabbitmq/rabbitmq-server#2384.

Apparently it was introduced by this change rabbitmq/rabbitmq-server@460a432 that makes exported parameter values to be proplists and not maps.

@michaelklishin michaelklishin added this to the 3.8.6 milestone Jun 26, 2020
@michaelklishin michaelklishin self-assigned this Jun 26, 2020
@michaelklishin michaelklishin changed the title CLI definition export-and-reimport incorrectly deserialises federation upstreams CLI definition export incorrectly deserialises federation upstreams Jun 26, 2020
@michaelklishin
Copy link
Member Author

This is how parameters in the problematic case are deserialised:

"parameters" => [
     %{
       "component" => "federation-upstream",
       "name" => "up-1",
       "value" => [
         ["ack-mode", "on-confirm"],
         ["trust-user-id", false],
         ["uri", "amqp://127.0.0.1:5672"]
       ],
       "vhost" => "/"
     },
     %{
       "component" => "shovel",
       "name" => "shovel-60",
       "value" => [
         ["ack-mode", "on-confirm"],
         ["dest-add-forward-headers", false],
         ["dest-protocol", "amqp091"],
         ["dest-queue", "shovel-60-dst"],
         ["dest-uri", "amqp://localhost:5672"],
         ["src-delete-after", "never"],
         ["src-protocol", "amqp091"],
         ["src-queue", "shovel-60-src"],
         ["src-uri", "amqp://localhost:5672"]
       ],
       "vhost" => "/"
     }
   ]

@michaelklishin
Copy link
Member Author

JSON file difference makes it clear it's an export_definitions issue:

"parameters": [
        {
            "component": "federation-upstream",
            "name": "up-1",
            "value": [
                [
                    "ack-mode",
                    "on-confirm"
                ],
                [
                    "trust-user-id",
                    false
                ],
                [
                    "uri",
                    "amqp://127.0.0.1:5672"
                ]
            ],
            "vhost": "/"
        },
        {
            "component": "shovel",
            "name": "shovel-60",
            "value": [
                [
                    "ack-mode",
                    "on-confirm"
                ],
                [
                    "dest-add-forward-headers",
                    false
                ],
                [
                    "dest-protocol",
                    "amqp091"
                ],
                [
                    "dest-queue",
                    "shovel-60-dst"
                ],
                [
                    "dest-uri",
                    "amqp://localhost:5672"
                ],
                [
                    "src-delete-after",
                    "never"
                ],
                [
                    "src-protocol",
                    "amqp091"
                ],
                [
                    "src-queue",
                    "shovel-60-src"
                ],
                [
                    "src-uri",
                    "amqp://localhost:5672"
                ]
            ],
            "vhost": "/"
        }
    ],

vs. HTTP API-produced one:

    "parameters": [
        {
            "value": {
                "ack-mode": "on-confirm",
                "trust-user-id": false,
                "uri": "amqp://127.0.0.1:5672"
            },
            "vhost": "/",
            "component": "federation-upstream",
            "name": "up-1"
        },
        {
            "value": {
                "ack-mode": "on-confirm",
                "dest-add-forward-headers": false,
                "dest-protocol": "amqp091",
                "dest-queue": "shovel-60-dst",
                "dest-uri": "amqp://localhost:5672",
                "src-delete-after": "never",
                "src-protocol": "amqp091",
                "src-queue": "shovel-60-src",
                "src-uri": "amqp://localhost:5672"
            },
            "vhost": "/",
            "component": "shovel",
            "name": "shovel-60"
        }
    ],

michaelklishin referenced this issue in rabbitmq/rabbitmq-server Jun 26, 2020
michaelklishin added a commit that referenced this issue Jun 26, 2020
otherwise it would be serialised as a list of pairs, which is
not the format the import path (or an operator) expects

Closes #435
@michaelklishin michaelklishin changed the title CLI definition export incorrectly deserialises federation upstreams CLI definition export incorrectly serialises federation upstreams Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant