redhat-performance / odf-grafana

Playbook and dashboards to help with ODF performance analysis
GNU General Public License v3.0
5 stars 11 forks source link

Space in prom_tarball not supported #23

Open mulbc opened 10 months ago

mulbc commented 10 months ago

When we have a space in the prom_tarball variable, the playbook run fails.

What I have tried:

  1. ansible-playbook deploy-local.yml -e prom_tarball=/home/cblum/Downloads/prometheus\ (1).tar.gz
  2. ansible-playbook deploy-local.yml -e prom_tarball='/home/cblum/Downloads/prometheus (1).tar.gz'
  3. ansible-playbook deploy-local.yml -e prom_tarball='"/home/cblum/Downloads/prometheus (1).tar.gz"'

1 and 2 fail at this location, complaining that the file does not exist:

https://github.com/pcuzner/odf-grafana/blob/e1a96187d4866f45c230ba2c4c00f840d7593b2b/roles/prepare/tasks/extract_tarball.yml#L18

[...]
TASK [prepare : Check prom_tarball variable is set] **********************************************************************************
skipping: [localhost]

TASK [prepare : Try to stat /home/cblum/Downloads/prometheus] ************************************************************************
ok: [localhost]

TASK [prepare : Fail of /home/cblum/Downloads/prometheus is not found] ***************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to find /home/cblum/Downloads/prometheus"}

PLAY RECAP ***************************************************************************************************************************
localhost                  : ok=6    changed=1    unreachable=0    failed=1    skipped=8    rescued=0    ignored=0  

Important to note is that somewhere the variable content is split at the space character, so that it checks if /home/cblum/Downloads/prometheus exists, which it really does not.

3 fails later in the run

The variable content this time is not split at first and it continues until https://github.com/pcuzner/odf-grafana/blob/e1a96187d4866f45c230ba2c4c00f840d7593b2b/roles/prepare/tasks/extract_tarball.yml#L27

[...]
TASK [prepare : Check prom_tarball variable is set] **********************************************************************************
skipping: [localhost]

TASK [prepare : Try to stat /home/cblum/Downloads/prometheus (1).tar.gz] *************************************************************
ok: [localhost]

TASK [prepare : Fail of /home/cblum/Downloads/prometheus (1).tar.gz is not found] ****************************************************
skipping: [localhost]

TASK [prepare : Ensure /home/cblum/.prometheus exists] *******************************************************************************
changed: [localhost]

TASK [prepare : Get size of Prometheus backup] ***************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}'", "delta": "0:00:00.002649", "end": "2023-11-21 10:43:21.686566", "msg": "non-zero return code", "rc": 2, "start": "2023-11-21 10:43:21.683917", "stderr": "/bin/sh: -c: line 1: syntax error near unexpected token `('\n/bin/sh: -c: line 1: `gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}''", "stderr_lines": ["/bin/sh: -c: line 1: syntax error near unexpected token `('", "/bin/sh: -c: line 1: `gzip -l /home/cblum/Downloads/prometheus (1).tar.gz | tail -n 1 | awk '{print $2}''"], "stdout": "", "stdout_lines": []}

PLAY RECAP ***************************************************************************************************************************
localhost                  : ok=7    changed=2    unreachable=0    failed=1    skipped=9    rescued=0    ignored=0   

I have found no easy and immediate way to fix this in the code, but wanted to leave this here so it can eventually be fixed.

Obvious workaround is to rename the file so that we don't have a space in it:

$ mv  '/home/cblum/Downloads/prometheus (1).tar.gz' /home/cblum/Downloads/prometheus-1.tar.gz  
$ ansible-playbook deploy-local.yml -e prom_tarball='/home/cblum/Downloads/prometheus-1.tar.gz'