From 647c202a91993d96e09ef403fc412ac7c0754259 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 18 Oct 2021 17:05:44 +0200 Subject: [PATCH] Fix molecule job This adds the possibility to sova uses a local file instead of downloading from github. This is required because the verification searchs for a specific failure, that recently was updated in the sova config file, and the test started to fail. So, now, we use a static sova config file to be used by the molecule, avoiding these kind of failures happen in the future. Change-Id: I2530188f1795a39ec6ec7e43c9ba118349c08541 --- roles/collect_logs/defaults/main.yml | 5 ++ roles/collect_logs/molecule/sova/converge.yml | 2 + roles/collect_logs/molecule/sova/prepare.yml | 88 +++++++++++++++++++ roles/collect_logs/tasks/sova.yml | 14 ++- 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/roles/collect_logs/defaults/main.yml b/roles/collect_logs/defaults/main.yml index cb94f2f..b5bf335 100644 --- a/roles/collect_logs/defaults/main.yml +++ b/roles/collect_logs/defaults/main.yml @@ -438,6 +438,11 @@ collect_log_types: - openstack - container +# This set sova to use the specified json file instead of downloading from +# internet. Right now it is used by molecule, only set this if you do not want +# to use the official sova-config file. +# sova_config_file: "/path/to/sova/json/file + # InfluxDB module settings influxdb_only_successful_tasks: true influxdb_measurement: test diff --git a/roles/collect_logs/molecule/sova/converge.yml b/roles/collect_logs/molecule/sova/converge.yml index 205677b..e3eac2d 100644 --- a/roles/collect_logs/molecule/sova/converge.yml +++ b/roles/collect_logs/molecule/sova/converge.yml @@ -3,6 +3,8 @@ hosts: all tasks: - name: Include collect_logs + vars: + sova_config_file: "{{ ansible_user_dir }}/workspace/logs/sova_config.json" include_role: name: collect_logs tasks_from: sova.yml diff --git a/roles/collect_logs/molecule/sova/prepare.yml b/roles/collect_logs/molecule/sova/prepare.yml index af71df8..cd572cb 100644 --- a/roles/collect_logs/molecule/sova/prepare.yml +++ b/roles/collect_logs/molecule/sova/prepare.yml @@ -15,3 +15,91 @@ No valid host was found. There are not enough hosts dest: '{{ ansible_user_dir }}/workspace/logs/quickstart_install.log' mode: 0644 + + - name: Create a sample sova config file + copy: + content: | + { + "patterns": { + "bmc": [ + { + "id": "Introspection_failed_cannot_get_IP_address", + "logstash": "", + "msg": "Introspection failed, cannot get IP address", + "pattern": "Introspection_failed_cannot_get_IP_address", + "tag": "infra" + } + ], + "console": [ + { + "id": "Not_enough_hosts", + "logstash": "", + "msg": "No valid host was found.", + "pattern": "Not_enough_hosts", + "tag": "info" + } + ], + "errors": [ + { + "id": "Buildah_pull_image_failed", + "logstash": "", + "msg": "Buildah pull image failed", + "pattern": "Buildah_pull_image_failed", + "tag": "info" + } + ], + "ironic-conductor": [ + { + "id": "Ironic_deployment_timeout", + "logstash": "", + "msg": "Ironic deployment timeout.", + "pattern": "Ironic_deployment_timeout", + "tag": "info" + } + ], + "logstash": [ + { + "id": "Ping_timeout_when_deploying_OC", + "logstash": "", + "msg": "Ping timeout when deploying OC.", + "pattern": "Ping_timeout_when_deploying_OC", + "tag": "infra" + } + ], + "registry_log": [ + { + "id": "Invalid_checksum_format", + "logstash": "", + "msg": "Invalid checksum format.", + "pattern": "Invalid_checksum_format", + "tag": "infra" + } + ], + "selinux": [ + { + "id": "selinux_denials_found", + "logstash": "", + "msg": "selinux denials found", + "pattern": "selinux_denials_found", + "tag": "code" + } + ], + "syslog": [ + { + "id": "service_FAIL", + "logstash": "", + "msg": "service FAIL", + "pattern": "service_FAIL", + "tag": "command_exe" + } + ] + }, + "regexes": [ + { + "name": "Not_enough_hosts", + "regex": "No\\ valid\\ host\\ was\\ found\\.\\ There\\ are\\ not\\ enough\\ hosts" + } + ] + } + dest: '{{ ansible_user_dir }}/workspace/logs/sova_config.json' + mode: 0644 diff --git a/roles/collect_logs/tasks/sova.yml b/roles/collect_logs/tasks/sova.yml index fa40e79..bb66110 100644 --- a/roles/collect_logs/tasks/sova.yml +++ b/roles/collect_logs/tasks/sova.yml @@ -9,10 +9,20 @@ retries: 3 # to avoid accidental failures due to networking or rate limiting delay: 60 register: pattern_config + when: sova_config_file is not defined + +- name: Load sova patterns from local file + command: cat "{{ sova_config_file }}" + register: sova_config_file_output + when: sova_config_file is defined + +- name: Set sova_config json content + set_fact: + sova_config: "{{ (sova_config_file is defined) | ternary((sova_config_file_output.stdout | from_json), pattern_config.json) }}" - name: Run sova task sova: - config: "{{ pattern_config.json }}" + config: "{{ sova_config }}" files: console: "{{ ansible_user_dir }}/workspace/logs/quickstart_install.log" errors: "/var/log/errors.txt" @@ -25,7 +35,7 @@ - name: Run sova task (denials) sova: - config: "{{ pattern_config.json }}" + config: "{{ sova_config }}" files: selinux: "/var/log/extra/denials.txt" result: "{{ ansible_user_dir }}/workspace/logs/selinux_denials.log"