oVirt / ovirt-engine

The oVirt Engine virtualization manager
Other
493 stars 259 forks source link

Fix comparison logic in ovirt_initial_validations Ansible role #869

Closed o0-o closed 1 year ago

o0-o commented 1 year ago

Affected version

Describe the bug

If elasticsearch_host or fluentd_elasticsearch_host are undefined, hosted-engine --deploy will fail (timeout waiting for the engine to add the host).

The tasks file is located here on the engine vm:

/usr/share/ansible/roles/oVirt.metrics/roles/ovirt_initial_validations/tasks/check_logging_collectors.yml

The following lines will fail if elasticsearch_host or fluentd_elasticsearch_host are undefined:

elasticsearch_host == None or elasticsearch_host is undefined fluentd_elasticsearch_host == None or fluentd_elasticsearch_host is undefined when: (fluentd_elasticsearch_host == "elasticsearch-server.example.com") or (fluentd_elasticsearch_host is undefined)

(Comparing undefined to anything will fail, even if is undefined appears later in the logic)

Possible solution:

elasticsearch_host | default(None) == None fluentd_elasticsearch_host | default(None) == None when: (fluentd_elasticsearch_host | default == "elasticsearch-server.example.com")

In the last case, I'm not sure what it's purpose is since it's a hard-coded example... is the role generated dynamically?

To reproduce

  1. hosted-engine --deploy --4

  2. Install pip3.11 and then netaddr on the engine VM immediately after the Python 3.11 is installed (per #867)

Expected behavior

The engine should not fail while adding its host.

Additional context

For anyone looking for a quick fix:

  1. Console into the engine vm from the host node:
virsh -c qemu:///system?authfile=/etc/ovirt-hosted-engine/virsh_auth.conf console HostedEngineLocal
  1. Set the elasticsearch_host and fluentd_elasticsearch_host to None in defaults:
printf '%s\n' 'elasticsearch_host:' 'fluentd_elasticsearch_host:' >> /usr/share/ansible/roles/oVirt.metrics/roles/ovirt_initial_validations/defaults/main.yml
michalskrivanek commented 1 year ago

This was fixed by https://github.com/oVirt/ovirt-engine-metrics/pull/35