[
https://issues.apache.org/jira/browse/AMBARI-8320?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14211386#comment-14211386
]
Enrique Flores commented on AMBARI-8320:
----------------------------------------
Applied the following change to configs.sh :
{code}
$ git diff
diff --git a/ambari-server/src/main/resources/scripts/configs.sh
b/ambari-server/src/main/resources/scripts/configs.sh
index 57fd2aa..1036c99 100755
--- a/ambari-server/src/main/resources/scripts/configs.sh
+++ b/ambari-server/src/main/resources/scripts/configs.sh
@@ -163,7 +163,7 @@ doConfigUpdate () {
doConfigFileUpdate () {
FILENAME=$1
if [ -f $FILENAME ]; then
- if [ "1" == "`grep -n \"\"properties\"\" $FILENAME | cut -d : -f 1`" ];
then
+ if [ "1" == "$(grep -n ^\"properties\" $FILENAME | cut -d : -f 1)" ]; then
newTag=`date "+%s%N"`
newTag="version${newTag}"
newProperties=`cat $FILENAME`;
{code}
Tried again and was successful:
{noformat}
[root@node-0 out2]# grep -n -o -P '(properties)\S+' hdfs-log4j.txt
1:properties"
2:properties\nhadoop.root.logger=INFO,console\nhadoop.log.dir=.\nhadoop.log.file=hadoop.log\n\n\n#
[root@node-0 out2]#
[root@node-0 out2]# bash -x /var/lib/ambari-server/resources/scripts/configs.sh
set localhost DC-2 hdfs-log4j hdfs-log4j.txt
+ USERID=admin
+ PASSWD=admin
+ PORT=:8080
+ SSL_URL_PREFIX=
+ '[' set == -u ']'
+ '[' set == -p ']'
+ '[' set == -port ']'
+ '[' set == -s ']'
+ AMBARIURL=http://localhost:8080
+ CLUSTER=DC-2
+ SITE=hdfs-log4j
+ SITETAG=
+ CONFIGKEY=hdfs-log4j.txt
+ CONFIGVALUE=
+ case "$1" in
+ (( 5 == 6 ))
+ (( 5 == 5 ))
+ doConfigFileUpdate hdfs-log4j.txt
+ FILENAME=hdfs-log4j.txt
+ '[' -f hdfs-log4j.txt ']'
++ cut -d : -f 1
++ grep -n '^"properties"' hdfs-log4j.txt
+ '[' 1 == 1 ']'
++ date +%s%N
+ newTag=1415916368703553931
+ newTag=version1415916368703553931
++ cat hdfs-log4j.txt
{noformat}
> configs.sh doConfigFileUpdate fails when multiple occurrences of word
> "properties" found
> -----------------------------------------------------------------------------------------
>
> Key: AMBARI-8320
> URL: https://issues.apache.org/jira/browse/AMBARI-8320
> Project: Ambari
> Issue Type: Bug
> Components: ambari-server
> Affects Versions: 1.6.1
> Reporter: Enrique Flores
>
> When running configs.sh to read in a properties file per doConfigFileUpdate,
> the update fails with the following error:
> {noformat}
> [root@node-0 out2]# bash -x
> /var/lib/ambari-server/resources/scripts/configs.sh set localhost DC-2
> hdfs-log4j hdfs-log4j.txt
> + USERID=admin
> + PASSWD=admin
> + PORT=:8080
> + SSL_URL_PREFIX=
> + '[' set == -u ']'
> + '[' set == -p ']'
> + '[' set == -port ']'
> + '[' set == -s ']'
> + AMBARIURL=http://localhost:8080
> + CLUSTER=DC-2
> + SITE=hdfs-log4j
> + SITETAG=
> + CONFIGKEY=hdfs-log4j.txt
> + CONFIGVALUE=
> + case "$1" in
> + (( 5 == 6 ))
> + (( 5 == 5 ))
> + doConfigFileUpdate hdfs-log4j.txt
> + FILENAME=hdfs-log4j.txt
> + '[' -f hdfs-log4j.txt ']'
> ++ cut -d : -f 1
> ++ grep -n properties hdfs-log4j.txt
> + '[' 1 == '1
> 2' ']'
> + echo '[ERROR] File "hdfs-log4j.txt" should be in the following JSON format:'
> [ERROR] File "hdfs-log4j.txt" should be in the following JSON format:
> + echo '[ERROR] "properties": {'
> [ERROR] "properties": {
> + echo '[ERROR] "key1": "value1",'
> [ERROR] "key1": "value1",
> + echo '[ERROR] "key2": "value2",'
> [ERROR] "key2": "value2",
> + echo '[ERROR] }'
> [ERROR] }
> + exit 1
> [root@node-0 out2]#
> {noformat}
> In this example, there are multiple occurrences of the word "properties" in
> the hdfs-log4j.txt properties file I'm trying to read in:
> {noformat}
> [root@node-0 out2]# grep -n properties hdfs-log4j.txt | cut -d: -f 1
> 1
> 2
> [root@node-0 out2]#
> [root@node-0 out2]# grep -n -o -P '(properties)\S+' hdfs-log4j.txt
> 1:properties"
> 2:properties\nhadoop.root.logger=INFO,console\nhadoop.log.dir=.\nhadoop.log.file=hadoop.log\n\n\n#
> [root@node-0 out2]#
> {noformat}
> The file I'm trying to read in is formatted properly , but configs.sh fails
> due to the grep test in doConfigFileUpdate not passing.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)