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

cisco.mso.mso_rest returns unhelpful error response (DCNE-49) #423

Open
phil-dotchon opened this issue May 23, 2024 · 4 comments
Open

cisco.mso.mso_rest returns unhelpful error response (DCNE-49) #423

phil-dotchon opened this issue May 23, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request jira-sync Sync this issue to Jira

Comments

@phil-dotchon
Copy link

phil-dotchon commented May 23, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

  • When using cisco.mso.mso_rest to patch NDO schema I ran into some issues. The code was previously working on earlier NDO (3.7.(1j)) and collection version (2.2.1), but after upgrade to 4.2.3e, along with update of the collection from 2.2.1 to 2.6.0 the code no longer worked. This problem is now resolved, but to find the cause I needed to use Postman as the output returned by mso-rest was quite unhelpful for some reason. The raw output returned from Postman, for the exact same request, provided a clear insight into what was going wrong in the API call

Affected Module Name(s):

  • mso_rest

MSO version and MSO Platform

  • V 4.2.3e and ND-based.

APIC version and APIC Platform for Site Level Resources

  • V 5.3(2b) and on-prem

Collection versions

  • cisco.mso 2.6.0

Output/ Error message

  • Output from mso_rest
{
    "attempts": 1,
    "changed": false,
    "current": {},
    "data": [
        {
            "op": "add",
            "path": "/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship",
            "value": {
                "serviceGraphContractRelationRef": {
                    "contractName": "CI9380650",
                    "schemaId": "663a169d216a38e187135157",
                    "serviceGraphName": "PA-5250-PBR_non-production",
                    "templateName": "CommonTemplate_001"
                },
                "serviceGraphRef": {
                    "schemaId": "663a169d216a38e187135157",
                    "serviceGraphName": "PA-5250-PBR_non-production",
                    "templateName": "CommonTemplate_001"
                },
                "serviceNodesRelationship": [
                    {
                        "consumerConnector": {
                            "bdRef": {
                                "bdName": "ips-pbr-transit_non-production_e-us1",
                                "schemaId": "663529ef216a38e187132625",
                                "templateName": "Infrastructure_e-us1"
                            },
                            "connectorType": "general"
                        },
                        "providerConnector": {
                            "bdRef": {
                                "bdName": "ips-pbr-transit_non-production_e-us1",
                                "schemaId": "663529ef216a38e187132625",
                                "templateName": "Infrastructure_e-us1"
                            },
                            "connectorType": "general"
                        },
                        "serviceNodeRef": {
                            "schemaId": "663a169d216a38e187135157",
                            "serviceGraphName": "PA-5250-PBR_non-production",
                            "serviceNodeName": "node1",
                            "templateName": "CommonTemplate_001"
                        }
                    }
                ]
            }
        }
    ],
    "httpapi_logs": [
        [
            "info",
            "send_request() - send_request method called"
        ],
        [
            "info",
            "send_request() - connection.send(/mso/api/v1/schemas/663a169d216a38e187135157?validate=false, [{\"op\": \"add\", \"path\": \"/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship\", \"value\": {\"serviceGraphRef\": {\"templateName\": \"CommonTemplate_001\", \"serviceGraphName\": \"PA-5250-PBR_non-production\", \"schemaId\": \"663a169d216a38e187135157\"}, \"serviceGraphContractRelationRef\": {\"templateName\": \"CommonTemplate_001\", \"serviceGraphName\": \"PA-5250-PBR_non-production\", \"contractName\": \"CI9380650\", \"schemaId\": \"663a169d216a38e187135157\"}, \"serviceNodesRelationship\": [{\"serviceNodeRef\": {\"templateName\": \"CommonTemplate_001\", \"serviceGraphName\": \"PA-5250-PBR_non-production\", \"schemaId\": \"663a169d216a38e187135157\", \"serviceNodeName\": \"node1\"}, \"consumerConnector\": {\"bdRef\": {\"templateName\": \"Infrastructure_e-us1\", \"bdName\": \"ips-pbr-transit_non-production_e-us1\", \"schemaId\": \"663529ef216a38e187132625\"}, \"connectorType\": \"general\"}, \"providerConnector\": {\"bdRef\": {\"templateName\": \"Infrastructure_e-us1\", \"bdName\": \"ips-pbr-transit_non-production_e-us1\", \"schemaId\": \"663529ef216a38e187132625\"}, \"connectorType\": \"general\"}}]}}], PATCH, {'Content-Type': 'application/json'})"
        ],
        [
            "vvv",
            "ESTABLISH HTTP(S) CONNECTFOR USER: xxxxxx TO https://e-us1-ndo.fis.lab:443"
        ],
        [
            "info",
            "login() - login method called for e-us1-ndo.fis.lab"
        ],
        [
            "info",
            "login() - previous auth not found sending login POST to e-us1-ndo.fis.lab"
        ],
        [
            "info",
            "login() - connection.send(/login, LOGIN_PAYLOAD_NOT_SHOWN, POST, {'Content-Type': 'application/json'})"
        ]
    ],
    "info": {
        "body": {
            "error": "There was an internal server error"
        },
        "connection": "close",
        "content-length": "46",
        "content-type": "application/json",
        "error": {
            "code": 200,
            "message": {
                "error": "There was an internal server error"
            }
        },
        "method": "PATCH",
        "msg": "OK (46 bytes)",
        "server": "nginx",
        "status": 500,
        "strict-transport-security": "max-age=31536000; includeSubDomains",
        "url": "https://e-us1-ndo.fis.lab:443/mso/api/v1/schemas/663a169d216a38e187135157?validate=false",
        "x-ratelimit-limit": "-1",
        "x-ratelimit-remaining": "-1",
        "x-ratelimit-reset": "1559582945"
    },
    "method": "PATCH",
    "msg": "MSO Error:",
    "payload": {
        "error": "There was an internal server error"
    },
    "response": "OK (46 bytes)",
    "socket": "/home/lc5648734/.ansible/pc/39504a262a",
    "status": 500,
    "url": "https://e-us1-ndo.fis.lab:443/mso/api/v1/schemas/663a169d216a38e187135157?validate=false"
}

Expected Behavior

  • Output from Postman
{
    "code": 400,
    "message": "site-local Contract CI9380650 in site e-us-site1 in template CommonTemplate_001: missing Service Graph configuration",
    "info": null
}

Actual Behavior

  • The output from the mso_rest module in Ansible seems to have lost/dropped the useful info returned by the API endpoint, so the helpful text explaining why the API call failed is missing. I would expect the module to give me the useful info so I could correct the code and not have to resort to constructing the faulty call in Postman in order to understand what is going wrong

Playbook tasks to Reproduce

    - name: Add service graph to template contract
      ignore_errors: true
      cisco.mso.mso_rest:
        host: "{{ ansible_host | mandatory }}"
        username: "{{ ansible_user | mandatory }}"
        password: "{{ ansible_password | mandatory }}"
        validate_certs: "{{ ansible_httpapi_validate_certs }}"
        use_ssl: "{{ ansible_httpapi_use_ssl }}"
        use_proxy: false
        timeout: "{{ mso_timeout | default(omit) }}"
        path: "/mso/api/v1/schemas/663a169d216a38e187135157"
        method: patch
        output_level: debug
        content:
          - op: add
            path: "/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship"
            value:
              serviceGraphRef:
                templateName: CommonTemplate_001
                serviceGraphName: PA-5250-PBR_non-production
                schemaId: 663a169d216a38e187135157
              serviceGraphContractRelationRef:
                templateName: CommonTemplate_001
                serviceGraphName: PA-5250-PBR_non-production
                contractName: CI9380650
                schemaId: 663a169d216a38e187135157
              serviceNodesRelationship:
                - serviceNodeRef:
                    templateName: CommonTemplate_001
                    serviceGraphName: PA-5250-PBR_non-production
                    schemaId: 663a169d216a38e187135157
                    serviceNodeName: node1
                  consumerConnector:
                    bdRef:
                      templateName: Infrastructure_e-us1
                      bdName: ips-pbr-transit_non-production_e-us1
                      schemaId: 663529ef216a38e187132625
                    connectorType: general
                  providerConnector:
                    bdRef:
                      templateName: Infrastructure_e-us1
                      bdName: ips-pbr-transit_non-production_e-us1
                      schemaId: 663529ef216a38e187132625
                    connectorType: general

Postman call:

https://x.x.x.x/mso/api/v1/schemas/663a169d216a38e187135157

[
    {
        "op": "add",
        "path": "/templates/CommonTemplate_001/contracts/CI9380650/serviceGraphRelationship",
        "value": {
            "serviceGraphRef": {
                "templateName": "CommonTemplate_001",
                "serviceGraphName": "PA-5250-PBR_non-production",
                "schemaId": "663a169d216a38e187135157"
            },
            "serviceGraphContractRelationRef": {
                "templateName": "CommonTemplate_001",
                "serviceGraphName": "PA-5250-PBR_non-production",
                "contractName": "CI9380650",
                "schemaId": "663a169d216a38e187135157"
            },
            "serviceNodesRelationship": [
                {
                    "serviceNodeRef": {
                        "templateName": "CommonTemplate_001",
                        "serviceGraphName": "PA-5250-PBR_non-production",
                        "schemaId": "663a169d216a38e187135157",
                        "serviceNodeName": "node1"
                    },
                    "consumerConnector": {
                        "bdRef": {
                            "templateName": "Infrastructure_e-us1",
                            "bdName": "ips-pbr-transit_non-production_e-us1",
                            "schemaId": "663529ef216a38e187132625"
                        },
                        "connectorType": "general"
                    },
                    "providerConnector": {
                        "bdRef": {
                            "templateName": "Infrastructure_e-us1",
                            "bdName": "ips-pbr-transit_non-production_e-us1",
                            "schemaId": "663529ef216a38e187132625"
                        },
                        "connectorType": "general"
                    }
                }
            ]
        }
    }
]

Important Factoids

The reason for the failure is that NDO now requires the template and site level contract service graph structures to be provided at the same time, in the same API call, whereas in previous versions this could be delivered as two separate calls.

References

  • #0000
@phil-dotchon phil-dotchon added the bug Something isn't working label May 23, 2024
@akinross akinross added enhancement New feature or request and removed bug Something isn't working labels May 23, 2024
@akinross
Copy link
Collaborator

Hi @phil-dotchon, I have added it to the todo for further investigation by the team. Thank you for making us aware.

@samiib samiib added the jira-sync Sync this issue to Jira label Aug 12, 2024
@github-actions github-actions bot changed the title cisco.mso.mso_rest returns unhelpful error response cisco.mso.mso_rest returns unhelpful error response (DCNE-49) Aug 12, 2024
@anvitha-jain anvitha-jain self-assigned this Aug 15, 2024
@anvitha-jain
Copy link
Collaborator

anvitha-jain commented Aug 15, 2024

Hi @phil-dotchon, I am unable to reproduce this error (tested on MSO collection v2.6 and v2.9), does this error occor on v2.9 as well?
Will it be possible to attach the complete playbook that generated this error?

I wanted to bring to your attention that modules are available for template and site-level Service graphs (mso_schema_template_service_graph, mso_schema_site_service_graph).

@anvitha-jain
Copy link
Collaborator

Hi @phil-dotchon, just following up on this issue. Are there any additional updates?

@phil-dotchon
Copy link
Author

Hi Anvitha, sorry for being slow. I can't really attach the whole playbook because it is very large and would have all kinds of dependencies, but I'll try to recreate a scenario using an empty schema when I can find some time.

I did look at the service graph modules some time ago, but there were still some parts missing then. In the meantime I have written a custom module that generates schema patches for multiple contracts in one pass; speed/performance has increasing become an issue for us, as some of our plays can take 40/50 minutes+ where we are deploying app environments with a lot of contracts, so removing Ansible loops where possible has helped speed things up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jira-sync Sync this issue to Jira
Projects
None yet
Development

No branches or pull requests

4 participants