sap-linuxlab / community.sap_install

Automation for SAP - Collection of Ansible Roles for various SAP software installation
Apache License 2.0
54 stars 57 forks source link

sap_swpm: Reduce sapinst log output to provide important information #568

Open marcelmamula opened 11 months ago

marcelmamula commented 11 months ago

Current failed check will dump huge amount of information directly from sapinst log files. This is amount that is not required for investigation of failure and we need to filter it out a bit. My test runs produced so many lines of output that it cleared my whole console, rendering actual ansible log useless, being replaced by part of sapinst log.

@sean-freeman @berndfinger Updated as I am currently testing sap_infrastructure and my SWPM is failing so I can test this.

Proposal to limit output to last 50 or so lines

- name: SAP SWPM - Verify if sapinst process finished successfully
  ansible.builtin.async_status:
    jid: "{{ __sap_swpm_register_sapinst_async_job.ansible_job_id }}"
  register: __sap_swpm_register_sapinst
  ignore_errors: true
  no_log: true

- name: SAP SWPM - Detect failure and show limited output
  ansible.builtin.fail:
    msg: "{{ __sap_swpm_register_sapinst.stdout_lines[-50:] }}"
  when: __sap_swpm_register_sapinst.finished != 1 or __sap_swpm_register_sapinst.rc != 0

Variation to show only ERROR, but it will cut off important part because Errors are multi line.

- name: SAP SWPM - Detect failure and show limited output
  ansible.builtin.fail:
    msg: "{{ __sap_swpm_register_sapinst.stdout_lines | select('match', 'ERROR.*') | list }}"
  when: __sap_swpm_register_sapinst.finished != 1 or __sap_swpm_register_sapinst.rc != 0

Affected line: https://github.com/sap-linuxlab/community.sap_install/blob/d047f9343f1bd2ac970e02b33964281a094f996d/roles/sap_swpm/tasks/swpm.yml#L84

sean-freeman commented 7 months ago

In my experience, 50 lines of SWPM error output is not enough to see where the error originated. At minimum I use tail -n 200 when doing this manually (which should not be close to wiping scrollback), although sometimes the whole log is needed to debug the failure.

I'm OK with the proposed change if 200 lines is used.

berndfinger commented 3 days ago

@marcelmamula Are you OK with 200 lines of output? I will then implement and test it.

kksat commented 2 days ago

@berndfinger @marcelmamula @sean-freeman another option would be to suppress non error messages. See example

https://github.com/redhat-sap/rh_operations/blob/4f2584de0651b58e4f99003e6bc0108ca4b71888/roles/sapinst/tasks/main.yml#L61

how to use parameter SAPINST_MESSAGE_CONSOLE_THRESHOLD

And here is default parameter value https://github.com/redhat-sap/rh_operations/blob/4f2584de0651b58e4f99003e6bc0108ca4b71888/roles/sapinst/defaults/main.yml#L26

One can get list of supported parameters for sapinst with

./sapinst -p

Also for your information https://help.sap.com/docs/SUPPORT_CONTENT/sl/3362916813.html