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

Changing property name results in error when redeployed #250

Open alexmaslenn opened 2 years ago

alexmaslenn commented 2 years ago

Description

After a service template deployed, a changing property name and deploying again can cause an error.

Steps

Consider having the following service template service.yaml:

tosca_definitions_version: tosca_simple_yaml_1_3

node_types:

  hello_type:
    derived_from: tosca.nodes.SoftwareComponent
    properties:
      test:
        type: string

topology_template:

  node_templates:

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

    hello:
      type: hello_type
      properties:
        test: test
      requirements:
        - host: my-workstation

After successfully executing the deployment with opera deploy service.yaml try changing property name (e.g to test2) in both node type and node template.

Current behaviour

Execution of the command opera deploy service.yaml -c returns the following error:

Traceback (most recent call last):
  File "/test/xopera/.venv/bin/opera", line 8, in <module>
    sys.exit(main())
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/cli.py", line 61, in main
    return args.func(args)
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/commands/deploy.py", line 70, in _parser_callback
    status = info(None, storage)["status"]
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/commands/info.py", line 156, in info
    topology = template.instantiate(storage)
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/template/topology.py", line 46, in instantiate
    return Instance(storage, itertools.chain.from_iterable(node.instantiate() for node in self.nodes.values()))
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/instance/topology.py", line 14, in __init__
    node.read()
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/instance/base.py", line 41, in read
    self.load(self.topology.read(self.tosca_id))
  File "/test/xopera/.venv/lib/python3.8/site-packages/opera/instance/base.py", line 50, in load
    self.attributes[k].load(v)
KeyError: 'test

Deleting .opera directory resolves the error.

Expected behaviour

No error is returned and deployment is successful.

anzoman commented 2 years ago

@alexmaslenn thanks for finding this!