tliron / puccini

Cloud topology management and deployment tools based on TOSCA
https://puccini.cloud
Apache License 2.0
91 stars 20 forks source link

unknown requirement reference in node template #74

Closed philippemerle closed 2 years ago

philippemerle commented 3 years ago

Puccuni 0.18.0 signals no problem on the following template:

tosca_definitions_version: tosca_simple_yaml_1_3
node_types:
  MyNodeType:
    requirements:
      - req:
          capability: tosca:Compute
          # default occurrences is [1, 1]
#          occurrences: [1, 1]
topology_template:
  substitution_mappings:
    node_type: MyNodeType
    requirements:
      req: [ node, req ]
  node_templates:
    node:
      type: MyNodeType

But if one uncomments occurrences: [1, 1] then Puccini signals two problems:

$ puccini-tosca compile previous_template.yaml
PROBLEMS (2)
  file:......./previous_template.yaml
    @16,5 topology_template.node_templates["node"].requirements: number of requirement "req" assignments is 0, must be >= 1 and <= 1
    @14,20 topology_template.substitution_mappings.requirements["req"][1]: unknown requirement reference in node template "node": req
$

The first problem is already reported in https://github.com/tliron/puccini/issues/73. The second problem illustrates that there are two totally different behaviours depending on the absence or presence of the occurrences keyname.

tliron commented 2 years ago

Thanks, I hope you can answer my question in #73 as to what your personal understanding of occurrences is for capabilities.

As for requirements, this is explained in a hidden place in the documentation, here.

I'll be honest -- I'm not sure what is the best way to handle this. In our TOSCA 2.0 discussions we seem to have agreed that if the minimum of the range is >0 then the TOSCA processor should automatically assign the minimum number of requirements, and thus would try to satisfy them. So, I'm thinking that if this is what we agreed for 2.0 then I should backport that functionality to 1.3.

What do you think?

tliron commented 2 years ago

I have gone ahead and implemented the TOSCA 2.0 behavior for all versions of TOSCA. To clarify:

1) The default occurrences for requirement definitions is [1,1]. 2) If you assign less than the lower bound then Puccini will automatically assign extra requirements to match the lower bound.

philippemerle commented 2 years ago

Thank @tliron.