balena-labs-projects / connector

Auto-configured data connector block based on Telegraf
15 stars 8 forks source link

Customisation feature broken? #48

Closed wjlove closed 2 years ago

wjlove commented 2 years ago

Under the "Extended image configuration" section of the readme.md it suggests that you can include your own Telegraf config file by using the dockerfile.template option. Currently this appears to not work due to an issue with how entry.sh generates the final exec command.

Per the readme.md file, using this in the template file:

FROM balenablocks/connector:%%BALENA_MACHINE_NAME%% COPY customTelegraf.conf . CMD ["--config customTelegraf.conf"]

generates the following error in the container:

<...snip...> 21.03.22 14:22:41 (-0400) 21.03.22 14:22:41 (-0400) balenaBlocks connector version: 1.1.2 21.03.22 14:22:41 (-0400) Changing hostname to c5ab484 21.03.22 14:22:41 (-0400) flag provided but not defined: -config ./customTelegraf.conf 21.03.22 14:22:41 (-0400) Telegraf, The plugin-driven server agent for collecting and reporting metrics. 21.03.22 14:22:41 (-0400) 21.03.22 14:22:41 (-0400) Usage: <...snip...>

note the missing dash in front of the config option, should be "--config ./customTelegraf.conf"

Changing the CMD line to: CMD [" --config customTelegraf.conf"] (note the space between the double quote and the first dash) generates a different error:

<...snip...> 21.03.22 14:27:38 (-0400) 21.03.22 14:27:38 (-0400) balenaBlocks connector version: 1.1.2 21.03.22 14:27:38 (-0400) Changing hostname to c5ab484 21.03.22 14:27:38 (-0400) /app/entry.sh: line 27: /app/ --config ./customTelegraf.conf: No such file or directory 21.03.22 14:27:39 (-0400) Service exited 'connector sha256:12372dfc2677cb971debefb074f19408c5ed77b7d10d65cce930745220980e99' <...snip...>

The option flag is now correct but the command to run appears to be "/app/" and not "./telegraf". I suspect there is something new with how this bit of code below from entry.sh is executed which I do not understand:

<...snip...>

If command starts with an option, prepend telegraf to it

if [[ "${1#-}" != "$1" ]]; then set -- ./telegraf "$@" fi

exec "$@" <...snip...>

wjlove commented 2 years ago

Closing issue as not fully vetted.