Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore functionality in docker entrypoint #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zsistla
Copy link
Contributor

@zsistla zsistla commented May 12, 2020

In speaking further with Johannes, he recalled the original functionality allowed for starting something in the container that was not our daemon.

I removed the last clause of the case statement to not assume that our daemon will be run and to allow the caller to run another command besides newrelic-daemon. It functionally behaves like the previous (non POSIX compatible) entry point.

However…
The functionality of this(old and new) is somewhat limited because it only works for commands that don't use preceding flags. For instance, both instances can run a command the following:

  docker build -t c-daemon .
  name=temp
  docker run -d --name $name c-daemon ls
  docker logs $name

and

  docker build -t c-daemon .
  name=temp
  docker run -d --name $name c-daemon ls -l
  docker logs $name

And you'll see the output in the logs. However, if you try to call any command that uses flags preceding the command, like:

docker run -d --name $name c-daemon -lt /bin/sh

We call the newrelic daemon with all flags and anything following the flags, so we'd call newrelic-daemon with -lt /bin/sh arguments.

The three use cases are then:
. Running the daemon with the full path: docker run -d --name $name c-daemon /usr/bin/newrelic-daemon --loglevel debug
. Running the daemon without specifying the daemon binary: docker run -d --name $name c-daemon --loglevel debug
. Running an arbitrary command that is NOT preceded by a flag: docker run -d --name $name c-daemon cat /var/log/newrelic-daemon.log

This has been tested by tests/image_tests.sh.

image_tests.sh has also been updated to test functionality of usage case #3.

zsistla added 3 commits May 7, 2020 17:15
…indexing is undefined:

`if [ "${1:0:1}" = '-' ];`
The logic has been replaced with POSIX sh compatible logic.
;;
*)
#likely invalid args, but the daemon will handle it with graceful messages.
set -- /usr/bin/newrelic-daemon $defaultArgs "$@"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this clause be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for catching that. It looks like that commit didn't make it for some reason. I'll redo the commit for that one again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants