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

Attribute assignments lost after update #262

Open milesstoetzner opened 1 year ago

milesstoetzner commented 1 year ago

Description

Hey,

I am having trouble with assigned attributes which are lost during an update of the service template. I encountered this problem when assigend public addresses of compute node templates have been lost.

Greetings Miles

Steps

Here is a minimal service template that should be deployed.

# service-template.yaml
tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
    node_dummy:
        derived_from: tosca.nodes.Root
        attributes: 
            some_attribute: 
                type: string
        interfaces:
            Standard:
                operations:
                    create: create.yaml

topology_template:
    node_templates:
        node_first:
            type: node_dummy

The deployment works as expected.

$ opera deploy service-template.yaml
[Worker_0]   Deploying node_first_0
[Worker_0]     Executing create on node_first_0
[Worker_0]   Deployment of node_first_0 complete

And we can see in .opera/instances/node_first_0 that the attribute some_attribute of the node template node_first has the value some_value.

{
  "tosca_name": {
    "is_set": true,
    "data": "node_first"
  },
  "tosca_id": {
    "is_set": true,
    "data": "node_first_0"
  },
  "state": {
    "is_set": true,
    "data": "started"
  },
  "some_attribute": {
    "is_set": true,
    "data": "some_value"
  }
}

However, if we update the service template with service-template.v2.yaml, then the assigned attribute ist lost even tho node_first should not be "touched" since its state is started.

# service-template.v2.yaml
tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
    node_dummy:
        derived_from: tosca.nodes.Root
        attributes: 
            some_attribute: 
                type: string
        interfaces:
            Standard:
                operations:
                    create: create.yaml

topology_template:
    node_templates:
        node_first:
            type: node_dummy

        node_second:
            type: node_dummy

The update command.

$ opera update service-template.v2.yaml
[Worker_0]   Deploying node_second_0
[Worker_0]     Executing create on node_second_0
[Worker_0]   Deployment of node_second_0 complete

The new content of .opera/instances/node_first_0 which has no value assigned to some_attribute.

{
  "tosca_name": {
    "is_set": true,
    "data": "node_first"
  },
  "tosca_id": {
    "is_set": true,
    "data": "node_first_0"
  },
  "state": {
    "is_set": true,
    "data": "started"
  },
  "component_version": {
    "is_set": false,
    "data": null
  },
  "admin_credential": {
    "is_set": false,
    "data": null
  },
  "some_attribute": {
    "is_set": false,
    "data": null
  }
}

The attribute has been assigned at node_second as exepcted.

{
  "tosca_name": {
    "is_set": true,
    "data": "node_second"
  },
  "tosca_id": {
    "is_set": true,
    "data": "node_second_0"
  },
  "state": {
    "is_set": true,
    "data": "started"
  },
  "some_attribute": {
    "is_set": true,
    "data": "some_value"
  }
}

Interestingly, when we add the node template node_second directly to the currently deployed service template service-template.yaml and resume the deployment, then the attribute assignment is obtained.

# service-template.yaml (directly updated)
tosca_definitions_version: tosca_simple_yaml_1_3

node_types:
    node_dummy:
        derived_from: tosca.nodes.Root
        attributes: 
            some_attribute: 
                type: string
        interfaces:
            Standard:
                operations:
                    create: create.yaml

topology_template:
    node_templates:
        node_first:
            type: node_dummy

        node_second:
            type: node_dummy
$ opera deploy --resume --force
[Worker_0]   Deploying node_second_0
[Worker_0]     Executing create on node_second_0
[Worker_0]   Deployment of node_second_0 complete

Expected Behaviour

I expect that assigned attributes of node templates, which are already deployed and are not touched during the update, are still assigned after the service template has been successfully updated.

milesstoetzner commented 1 year ago

Here is also the Ansible playbook.

# create.yaml
- hosts: all
  gather_facts: false
  tasks:
      - name: Set attributes
        set_stats:
            data:
              some_attribute: some_value