Ask Your Question

Conditional resource properties (not conditional values)

asked 2020-03-02 16:47:58 -0500

MichaelKostan gravatar image

Kia Ora :) Is there a smarter way to deal with conditional resource properties themselves (not their values)?

My limited view makes me believe, that a single resource property item (not its value/content) can't be conditional and that additional resource structures are needed to cater for variations.

For example:

Octavia::HealthMonitor type: HTTP - requires three additional properties http_method, url_path and expected_codes

Octavia::HealthMonitor type: TCP - doesn’t require these additional properties, but produces errors if they are used/set anyway

Currently I define two HealthMonitor resources in my HEAT template to deal with different types:

    type: OS::Octavia::HealthMonitor
      pool: myPool
      max_retries: 3
      delay: 5
      timeout: 5
      type: HTTP
      http_method: GET
      url_path: /index.html
      expected_codes: 200
   condition: typeIsHTTP

    type: OS::Octavia::HealthMonitor
      pool: myPool
      max_retries: 3
      delay: 5
      timeout: 5
      type: TCP
   condition: typeIsTCP

In this case its not an issue as a health monitor doesn’t have any child resources. However, changing resource names can trip you over if children must reference a resource (get_resource: name?)

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-03-03 10:22:32 -0500

zaneb gravatar image

You can pass null as a value, and that's equivalent to not specifying the property at all:

http_method: {if: [typeIsHTTP, GET, null]}
edit flag offensive delete link more


Zaneb - Thanks for your time. Keenly and unlucky, I did put your null value to "unspecify" resource properties theory to the test. Setting http_method: null and type: TCP produces the error "Property "" is not an allowed value. Creative ideas?

MichaelKostan gravatar imageMichaelKostan ( 2020-03-04 21:26:13 -0500 )edit

You're right, on further investigation that doesn't work. I have an idea for how to implement this feature, and I opened a bug for it.

zaneb gravatar imagezaneb ( 2020-03-05 23:19:12 -0500 )edit

Thanks heaps Zaneb for picking this up and showing me/us the ways. You are so helpful. Your proposal should allow for smarter template coding in the future. Sorry that I cant help further. Ta ta

MichaelKostan gravatar imageMichaelKostan ( 2020-03-08 14:45:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2020-03-02 16:47:58 -0500

Seen: 25 times

Last updated: Mar 03