When a *Count parameter is set as a string in yaml the error is incomprehensible

Bug #1828305 reported by Michele Baldessari
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
High
Michele Baldessari

Bug Description

If you wrongly pass one of the *Count parameters as a string instead of an integer the error will be unintelligible:
composable_roles/config_heat.yaml: ControllerOpenstackCount: '3'

...

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 30, in run
    super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/lib/python3.6/site-packages/cliff/command.py", line 184, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 919, in take_action
    self._deploy_tripleo_heat_templates_tmpdir(stack, parsed_args)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 374, in _deploy_tripleo_heat_templates_tmpdir
    new_tht_root, tht_root)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 477, in _deploy_tripleo_heat_templates
    deployment_options=deployment_options)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 494, in _try_overcloud_deploy_with_compat_yaml
    deployment_options=deployment_options)
  File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_deploy.py", line 247, in _heat_deploy
    deployment_options=deployment_options)
  File "/usr/lib/python3.6/site-packages/tripleoclient/workflows/deployment.py", line 81, in deploy_and_wait
    deploy(log, clients, **workflow_input)
  File "/usr/lib/python3.6/site-packages/tripleoclient/workflows/deployment.py", line 63, in deploy
    % (payload['status'], wf_name))
ValueError: Unexpected status FAILED for tripleo.deployment.v1.deploy_plan
Unexpected status FAILED for tripleo.deployment.v1.deploy_plan
Removing the current plan files
Uploading new plan files
Plan updated.

So the problem happens because even before heat can validate *Count params as number types, we call the following code in tripleo_common:
    parameter_defaults = environment.get('parameter_defaults', {})
    for role in roles_data:
        count = parameter_defaults.get('%sCount' % role['name'],
                                       role.get('CountDefault', 0))
        if count > 0:
            enabled_services.update(
                parameter_defaults.get('%sServices' % role['name'],
                                       role.get('ServicesDefault', [])))

And since ControllerOpenstackCount is a string and not a number, the deploy fails.

Revision history for this message
Michele Baldessari (michele) wrote :

The full stack trace is:
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images [req-28e3f868-8595-4bef-96d3-8e453c1e15d1 00a9a3ac3ac34f5da5cc75fc6723e6ae c37c1c5cde444df0935c8a17a1eae610 - default default] Error occurred while processing plan files.: TypeError: '>' not supported between instances of 'str' and 'int'
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images Traceback (most recent call last):
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/actions/container_images.py", line 141, in run
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images env, role_data, dry_run=True)
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 156, in container_images_prepare_multi
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images service_filter = build_service_filter(environment, roles_data)
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 90, in build_service_filter
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images enabled_services = get_enabled_services(environment, roles_data)
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 74, in get_enabled_services
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images if count > 0:
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images TypeError: '>' not supported between instances of 'str' and 'int'
2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (master)

Fix proposed to branch: master
Review: https://review.opendev.org/657896

Changed in tripleo:
status: Triaged → In Progress
Changed in tripleo:
milestone: none → train-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (master)

Reviewed: https://review.opendev.org/657896
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=5dcad57220cb495b907b6e2b4d355b1517444df8
Submitter: Zuul
Branch: master

commit 5dcad57220cb495b907b6e2b4d355b1517444df8
Author: Michele Baldessari <email address hidden>
Date: Wed May 8 23:56:52 2019 +0200

    Make get_enabled_services() more robust

    If you wrongly pass one of the *Count parameters as a string instead of an integer the error will be unintelligible:
    composable_roles/config_heat.yaml: ControllerOpenstackCount: '3'

    ...
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images [req-28e3f868-8595-4bef-96d3-8e453c1e15d1 00a9a3ac3ac34f5da5cc75fc6723e6ae c37c1c5cde444df0935c8a17a1eae610 - default default] Error occurred while processing plan files.: TypeError: '>' not supported between instances of 'str' and 'int'
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images Traceback (most recent call last):
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/actions/container_images.py", line 141, in run
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images env, role_data, dry_run=True)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 156, in container_images_prepare_multi
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images service_filter = build_service_filter(environment, roles_data)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 90, in build_service_filter
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images enabled_services = get_enabled_services(environment, roles_data)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 74, in get_enabled_services
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images if count > 0:
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images TypeError: '>' not supported between instances of 'str' and 'int'
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images

    So the problem happens because even before heat can validate *Count params as
    number types, we read the parameter from the plan and see if it is bigger than 0.

    Let's try and convert any *Count variable to an integer. Heat seems to have no issues
    with it and it is likely that this usage (as created by infrared) has been here in
    previous OpenStack versions anyways.

    Tested with this change and correctly got past the Mistral error and a successful heat-deploy.

    Change-Id: Ibf8ea77d5c320b10b6e0dabe1356bad62882fcb6
    Closes-Bug: #1828305

Changed in tripleo:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-common (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/658151

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-common (stable/stein)

Reviewed: https://review.opendev.org/658151
Committed: https://git.openstack.org/cgit/openstack/tripleo-common/commit/?id=a9e05d47504330b99716b3e253b5247e397744a2
Submitter: Zuul
Branch: stable/stein

commit a9e05d47504330b99716b3e253b5247e397744a2
Author: Michele Baldessari <email address hidden>
Date: Wed May 8 23:56:52 2019 +0200

    Make get_enabled_services() more robust

    If you wrongly pass one of the *Count parameters as a string instead of an integer the error will be unintelligible:
    composable_roles/config_heat.yaml: ControllerOpenstackCount: '3'

    ...
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images [req-28e3f868-8595-4bef-96d3-8e453c1e15d1 00a9a3ac3ac34f5da5cc75fc6723e6ae c37c1c5cde444df0935c8a17a1eae610 - default default] Error occurred while processing plan files.: TypeError: '>' not supported between instances of 'str' and 'int'
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images Traceback (most recent call last):
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/actions/container_images.py", line 141, in run
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images env, role_data, dry_run=True)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 156, in container_images_prepare_multi
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images service_filter = build_service_filter(environment, roles_data)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 90, in build_service_filter
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images enabled_services = get_enabled_services(environment, roles_data)
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images File "/usr/lib/python3.6/site-packages/tripleo_common/image/kolla_builder.py", line 74, in get_enabled_services
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images if count > 0:
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images TypeError: '>' not supported between instances of 'str' and 'int'
    2019-05-02 04:58:01.962 9 ERROR tripleo_common.actions.container_images

    So the problem happens because even before heat can validate *Count params as
    number types, we read the parameter from the plan and see if it is bigger than 0.

    Let's try and convert any *Count variable to an integer. Heat seems to have no issues
    with it and it is likely that this usage (as created by infrared) has been here in
    previous OpenStack versions anyways.

    Tested with this change and correctly got past the Mistral error and a successful heat-deploy.

    Change-Id: Ibf8ea77d5c320b10b6e0dabe1356bad62882fcb6
    Closes-Bug: #1828305
    (cherry picked from commit 5dcad57220cb495b907b6e2b4d355b1517444df8)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 11.0.0

This issue was fixed in the openstack/tripleo-common 11.0.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-common 10.8.0

This issue was fixed in the openstack/tripleo-common 10.8.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.