Project

General

Profile

Bug #20877

glidein_config parsing cutting the results at the first space

Added by Marco Mambelli over 1 year ago. Updated 12 months ago.

Status:
Closed
Priority:
High
Category:
Glidein
Target version:
Start date:
09/18/2018
Due date:
% Done:

0%

Estimated time:
First Occurred:
Occurs In:
Stakeholders:
Duration:

Description

In the glidein, the file glidein_config is used to communicate variables between scripts using the format:

var_name var_value
# Comment line

Most shell scripts use the following to parse it:
"`grep -i "^VAR_NAME " $glidein_config | awk '{print $2}'`"

This cuts the result at the first space:
var_name var_containing many spaces

Becomes only "var_containing", even if it is quoted
This has been OK so far, is being addressed in [#20871] for collectors and ccbs strings and the rest will be addressed in this ticket.

An expression like `grep -i "^VAR_NAME " $glidein_config | awk '{$1=""; print $0}'` (used already in part of the code) would solve the problem.
Bash variable mengling would also be OK tmp="`grep -i "^VAR_NAME " $glidein_config `"; echo "${tmp#* }"

History

#1 Updated by Marco Mambelli over 1 year ago

  • Assignee changed from Marco Mambelli to Lorena Lobato Pardavila

#2 Updated by Marco Mambelli over 1 year ago

  • Assignee changed from Lorena Lobato Pardavila to Marco Mambelli

#3 Updated by Marco Mambelli over 1 year ago

Using lines like:

"`grep -i "^VAR_NAME " "$glidein_config" | cut -d ' ' -f 2-`" 

This is preserving all the line after the first space:
- if the value contains spaces, the whole value will be returned, not only until the space (this will help if filenames have spaces or if values like the collectors do)
- the value is not trimmed. If there are extra spaces in the file, these may cause trouble

Lines like

"`grep -i "^VAR_NAME " "$glidein_config" | awk '{$1=""; print $0}'`" 

Could work as well. The differences are that:
- this adds a space at the beginning (see next). For condor variables this is OK, for file names may be a problem
- awk is not preserving the rest of the line as it is: it is tokenizing it, so multiple spaces (and tabs, ...) become one space, and is trimming it (initial and final spaces are removed). Since the 1st variable is nixed, the result starts with the separator after the first variable (a space)
- awk is heavier to invoke and run

That's why solution 1 is preferred.

I tested branch v34/20877 on gwms-dev machines and a smoke test worked successfully (jobs ran OK)

#4 Updated by Marco Mambelli over 1 year ago

  • Status changed from New to Feedback
  • Assignee changed from Marco Mambelli to Marco Mascheroni
  • Priority changed from Urgent to High

#5 Updated by Marco Mambelli over 1 year ago

  • Status changed from Feedback to Resolved
  • Assignee changed from Marco Mascheroni to Marco Mambelli
  • Target version changed from v3_4_1 to v3_5

#6 Updated by Marco Mambelli about 1 year ago

  • Target version changed from v3_5 to v3_4_3

#7 Updated by Marco Mambelli 12 months ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF