xlab-si / xopera-opera

xOpera orchestrator compliant with TOSCA YAML v1.3 in the making
https://xlab-si.github.io/xopera-docs/
Apache License 2.0
35 stars 14 forks source link

Mixed error output in synchronous failure #234

Closed alexmaslenn closed 2 years ago

alexmaslenn commented 2 years ago

Current behaviour

In the situation when multiple node operations fail simultaneously, xOpera output becomes mixed and distorted. For instance a multiworker deployment of a service template with 2 nodes that fail at the same moment

tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
  hello_type:
    derived_from: tosca.nodes.SoftwareComponent
    interfaces:
      Standard:
        type: tosca.interfaces.node.lifecycle.Standard
        operations:
          create:
            implementation: playbooks/create.yaml

topology_template:

  node_templates:
    my-workstation:
      type: tosca.nodes.Compute
      attributes:
        private_address: localhost
        public_address: localhost

    hello1:
      type: hello_type
      requirements:
        - host: my-workstation

    hello2:
      type: hello_type
      requirements:
        - host: my-workstation

(e.g with a create playbook like this)

---
- hosts: all
  gather_facts: false

  tasks:
    - name: Sleep
      command:
        cmd: sleep 5

    - name: Fail
      fail:
        msg: Failed.

the output would be

{
    {
        "custom_stats": {},
        "custom_stats": {},
        "global_custom_stats": {},
        "plays": [
            "global_custom_stats": {},
            "plays": [
                {
                    {
                        "play": {
                            "play": {
                                "duration": {
                                    "duration": {
                                        "end": "2021-12-22T12:19:31.349852Z",
                                        "end": "2021-12-22T12:19:31.349288Z",
                                        "start": "2021-12-22T12:19:21.156481Z"
                                    },
                                    "start": "2021-12-22T12:19:21.158668Z"                "id": "00155d04-387c-5bcf-eae2-000000000006",
                                },
                                "name": "all"                "id": "00155d04-387c-4e61-53d3-000000000006",
                                "name": "all"
                            },
                        },

Expected behaviour

Error outputs should be provided one after another. A lock object should be introduced to eliminate race condition in thread output.

anzoman commented 2 years ago

@alexmaslenn that's a very good find, we need to fix this bug.