Jbalkind commented on issue #3428: Broken resolvers config in apigateway 
container
URL: 
https://github.com/apache/incubator-openwhisk/issues/3428#issuecomment-417413707
 
 
   I have been seeing this same problem, running OpenWhisk in an Ubuntu 18.04 
VM in Qemu. I figured out what's happening and it's not upstream alpine's fault.
   
   The `/etc/api-gateway/conf.d/includes/resolvers.conf` file is creaetd by the 
incubator-openwhisk-apigateway `init.sh` script, in particular the following 
line ([see 
inline](https://github.com/apache/incubator-openwhisk-apigateway/blob/master/init.sh#L58)):
   
   ```
   echo resolver $(awk 'BEGIN{ORS=" "} /nameserver/{print $2}' /etc/resolv.conf 
| sed "s/ $/;/g") > /etc/api-gateway/conf.d/includes/resolvers.conf
   ```
   
   At the face of it, this seems correct. The problem is that there are 
comments at the start of the file. They look like this on my system:
   
   ```
   # Dynamic resolv.conf(5) file for glibc resolver(3) generated by 
resolvconf(8)
   #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
   # 127.0.0.53 is the systemd-resolved stub resolver.
   # run "systemd-resolve --status" to see details about the actual nameservers.
   ```
   
   The last line of the comment matches the awk command as it contains 
`nameserver`. Then, as the awk command says, it prints the 2nd token on the 
line, which is the word `run`.
   
   This can be simply solved by changing the awk command to:
   ```
   awk 'BEGIN{ORS=" "} /^nameserver/{print $2}' /etc/resolv.conf
   ```
   or, for something more robust (in case there's space before `nameserver`), 
you could go for:
   ```
   awk 'BEGIN{ORS=" "} /^[[:space:]]*nameserver/{print $2}' /etc/resolv.conf
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to