Skip to content

Conversation

@lag-linaro
Copy link
Contributor

When this project last attempted to become part of Docker Official Images, it was heavily reviewed.

This PR attempts to address each of the issues raised by @tianon.

For reference, the last review took place here:

LINK: docker-library/official-images#3724 (comment)

@repeatedly
Copy link
Member

Currently, many users use onbuild images to use 3rd party plugins and own configuration.
So we need the announcement for changes and need feedback from users.

@lag-linaro
Copy link
Contributor Author

Okay, understood.

How about the remainder of the changes?

@tianon
Copy link

tianon commented Nov 21, 2018 via email

@lag-linaro
Copy link
Contributor Author

Thanks @tianon. A review from you would be good.

Copy link

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Had a bit of spare time so I took a first pass. 👍


# If user does not supply config file or plugins, use the default
if [ "$1" == "fluentd" ]; then
if ! echo $@ | grep '\-c' ; then
Copy link

Choose a reason for hiding this comment

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

This grep is a little bit hacky -- if given multiple -c options, does fluentd not simply prefer the last one specified? It appears to:

$ docker run --rm fluent/fluentd:v1.2.3-debian fluentd -c /dev/null -c /fluentd/etc/fluent.conf
2018-11-22 18:38:07 +0000 [info]: parsing config file is succeeded path="/fluentd/etc/fluent.conf"
...

So these default flags could instead be specified like this:

if [ "$1" = 'fluentd' ]; then
	shift # remove 'fluentd' so we can prepend easier
	set -- fluentd -c /fluentd/etc/fluent.conf -p /fluentd/plugins "$@" # set defaults for "-c" and "-p" (which are then overrideable via the container command)
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems even hackier than my solution. Don't you think this will confuse users?

Copy link

Choose a reason for hiding this comment

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

By "hacky", I mean "fragile". With the current solution, if there's the string -c anywhere in the supplied arguments, it will not apply the default configuration, which is more likely to break.

For the purposes of the official images, I'm much more concerned with the user's usage patterns than what the final generated command ends up being (multiple -c parameters would likely be slightly more confusing for users, but that can be trivially mitigated here by a comment that explains that the behavior of fluentd is to prefer the last-specified-flag for each option given, which is why these get pre-pended to the front of the command string instead of appended to the end). The end goal is to have a reliable means of supplying a default configuration file and a trivial way for users to override it, which the solution I've proposed will provide in all cases I've tested, which I can't say about echo ... | grep '\-c'. The echo solution would be slightly better with something like haveConfig=; for arg; do if [ "$arg" = '-c' ]; then haveConfig=1; break; fi; done; if [ -z "$haveConfig" ]; then set -- "$@" -c ...; fi, but is significantly more verbose.

I think this is likely another place to solicit preference from the maintainer (@repeatedly). 👍

Copy link
Contributor Author

@lag-linaro lag-linaro Nov 26, 2018

Choose a reason for hiding this comment

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

The latter solution won't catch instances of -c/fluentd/etc/fluent.conf which is still valid.

How about I expand my solution to if ! echo $@ | grep '<SPACE>\-c' ; then, since <SPACE>-[a-zA-Z0-9] should always (?) be treated as a flagged argument, there shouldn't be any false positives and should therefore be less fragile.

set -o allexport
source $DEFAULT
set +o allexport
fi
Copy link

Choose a reason for hiding this comment

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

Is this sourcing code just to set (the now-removed) FLUENTD_CONF and FLUENTD_OPT variables or does it have other uses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea. I guess this is one for @repeatedly.

Copy link
Member

Choose a reason for hiding this comment

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

does it have other uses?

Fluentd users sometimes set own environment variable via this mechanizm.
So this image keeps same mechaznim.

fi
fi

exec gosu fluent "$@"
Copy link

Choose a reason for hiding this comment

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

Would it be worthwhile to update this for allowing arbitrary --user values? ie something like:

if [ "$(id -u)" = '0' ]; then
	exec gosu fluent "$@"
else
	exec "$@"
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure this is required for this project.

Best ask @repeatedly.

Copy link
Member

Choose a reason for hiding this comment

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

Is it important for official images?
We can add this change after become official, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Judging by the language @tianon uses here, I would say that it is not a blocker for Official Images.

Thus adding this change as a subsequent PR sounds reasonable.

@lag-linaro
Copy link
Contributor Author

Thanks for your review @tianon. I will have a look at fixing (mostly adding really) your comments.

@lag-linaro lag-linaro force-pushed the convert-to-docker-official-images branch from 4ff7f21 to f38a9dc Compare November 23, 2018 15:24
lag-linaro pushed a commit to lag-linaro/fluentd-docker-image that referenced this pull request Nov 23, 2018
Note that we can't convert Alpine ARMHF images, as they are not pushed to Docker Hub.

This issue was highlighted by @tianon

  LINK: fluent#152 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
@lag-linaro
Copy link
Contributor Author

Phew! Okay @tianon should be all done.

I didn't change the semantics where we search for the -c flag and insert the default one if absent, since I thought having more than one configuration/plugin argument on the command line would be more confusing and is more of a hack than the current implementation.

Everything else has been fixed up though.

I'd really appreciate a review from both @tianon and @repeatedly so we can have this merged. 😃

@edsiper
Copy link
Member

edsiper commented Nov 23, 2018

question:

is it time to get rid of Alpine images ?, basically without Jemalloc there is a lot of memory fragmentation on high load environments, I don't see how that is healthy in a containerized environment.

@tianon
Copy link

tianon commented Nov 23, 2018

is it time to get rid of Alpine images ?, basically without Jemalloc there is a lot of memory fragmentation on high load environments, I don't see how that is healthy in a containerized environment.

For the official images, the backwards compatibility concern with removing isn't a large concern (so this would be fine from our perspective), but the real call there is likely up to @repeatedly (we don't have a strong preference either way). 👍

@lag-linaro
Copy link
Contributor Author

@repeatedly could you please review the PR?

@edsiper
Copy link
Member

edsiper commented Nov 29, 2018

@lag-linaro

I did a quick build test and found the following problem in one of the arm images:

docker build   -t fluent/fluentd:v1.3.0-debian-armhf v1.3/armhf/debian --build-arg VERSION=v1.3.0-debian-armhf
Sending build context to Docker daemon  9.728kB
Step 1/21 : FROM resin/armv7hf-debian:stretch
 ---> b23e2470b550
Step 2/21 : ARG VERSION=1.1
 ---> Using cache
 ---> 251d8834050f
Step 3/21 : LABEL maintainer "TAGOMORI Satoshi <[email protected]>"
 ---> Using cache
 ---> ea48e88ac954
Step 4/21 : LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version=${VERSION}
 ---> Using cache
 ---> 59058334f972
Step 5/21 : ARG CROSS_BUILD_START="cross-build-start"
 ---> Using cache
 ---> a1833a170101
Step 6/21 : ARG CROSS_BUILD_END="cross-build-end"
 ---> Using cache
 ---> 62443ed896c8
Step 7/21 : RUN [ ${CROSS_BUILD_START} ]
 ---> Using cache
 ---> 8c90c07e36f5
Step 8/21 : ENV TINI_VERSION=0.18.0
 ---> Using cache
 ---> 5e9d869d34b3
Step 9/21 : ENV GOSU_VERSION=1.10-1+b2
 ---> Using cache
 ---> e50b7f9f140e
Step 10/21 : RUN apt-get update  && apt-get install -y --no-install-recommends             ca-certificates             ruby             tini             gosu=${GOSU_VERSION}  && buildDeps="       make gcc g++ libc-dev       ruby-dev       wget bzip2 gnupg dirmngr     "  && apt-get install -y --no-install-recommends $buildDeps  && echo 'gem: --no-document' >> /etc/gemrc  && gem install oj -v 3.3.10  && gem install json -v 2.1.0  && gem install fluentd -v 1.3.0  && gosu nobody true  && wget -O /tmp/jemalloc-4.5.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2  && cd /tmp && tar -xjf jemalloc-4.5.0.tar.bz2 && cd jemalloc-4.5.0/  && ./configure && make  && mv lib/libjemalloc.so.2 /usr/lib  && apt-get purge -y --auto-remove                   -o APT::AutoRemove::RecommendsImportant=false                   $buildDeps  && rm -rf /var/lib/apt/lists/*  && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
 ---> Running in dccd4e6822a9
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [2434 B]
Get:6 http://security.debian.org/debian-security stretch/updates/main armhf Packages [445 kB]
Get:7 http://deb.debian.org/debian stretch-updates/main armhf Packages [5108 B]
Get:8 http://deb.debian.org/debian stretch/main armhf Packages [6919 kB]
Fetched 7675 kB in 10s (699 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package tini
The command '/bin/sh -c apt-get update  && apt-get install -y --no-install-recommends             ca-certificates             ruby             tini             gosu=${GOSU_VERSION}  && buildDeps="       make gcc g++ libc-dev       ruby-dev       wget bzip2 gnupg dirmngr     "  && apt-get install -y --no-install-recommends $buildDeps  && echo 'gem: --no-document' >> /etc/gemrc  && gem install oj -v 3.3.10  && gem install json -v 2.1.0  && gem install fluentd -v 1.3.0  && gosu nobody true  && wget -O /tmp/jemalloc-4.5.0.tar.bz2 https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2  && cd /tmp && tar -xjf jemalloc-4.5.0.tar.bz2 && cd jemalloc-4.5.0/  && ./configure && make  && mv lib/libjemalloc.so.2 /usr/lib  && apt-get purge -y --auto-remove                   -o APT::AutoRemove::RecommendsImportant=false                   $buildDeps  && rm -rf /var/lib/apt/lists/*  && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem' returned a non-zero code: 100
make[1]: *** [Makefile:60: image] Error 100

looks like related to the missing dependency:

E: Unable to locate package tini

@lag-linaro
Copy link
Contributor Author

Thank you for testing this @edsiper.

Ah, I didn't test the armhf build since it won't be part of the Official Images suite. I will do so in future.

I can fix this, although what I'd really like to do is remove the cross-complied armhf build entirely.

The main/default Dockerfile should support armhf (and all the other architectures) without issue.

@lag-linaro lag-linaro force-pushed the convert-to-docker-official-images branch 2 times, most recently from d6aaa84 to da77e14 Compare November 30, 2018 09:04
lag-linaro pushed a commit to lag-linaro/fluentd-docker-image that referenced this pull request Nov 30, 2018
Note that we can't convert Alpine ARMHF images, as they are not pushed to Docker Hub.

This issue was highlighted by @tianon

  LINK: fluent#152 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
@lag-linaro
Copy link
Contributor Author

This pull-request has been rebased, so no more merge conflicts.

The Travis failures are due to GPG issues (which aren't anything to do with this PR) and on-build issues where the images are missing. The latter will be automatically rectified once we're in Official Images.

@runningman84
Copy link

@lag-linaro do you have some build already published somewhere? I have a mixed k8s env with amd64/arm64 and would be happy to test if I can deploy it with the same daemonset...

Copy link
Member

@repeatedly repeatedly left a comment

Choose a reason for hiding this comment

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

By this patch, we remove FLIENT_UID for #78
We should document proper way for id mapping.

If we break backward compatibility, we should add version tag to new images?
fluent/fluentd-kubernetes-daemonset#213

set -o allexport
source $DEFAULT
set +o allexport
fi
Copy link
Member

Choose a reason for hiding this comment

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

does it have other uses?

Fluentd users sometimes set own environment variable via this mechanizm.
So this image keeps same mechaznim.

fi
fi

exec gosu fluent "$@"
Copy link
Member

Choose a reason for hiding this comment

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

Is it important for official images?
We can add this change after become official, right?

@lag-linaro
Copy link
Contributor Author

@lag-linaro do you have some build already published somewhere? I have a mixed k8s env with amd64/arm64 and would be happy to test if I can deploy it with the same daemonset...

I can push a build for you if it helps?

@lag-linaro
Copy link
Contributor Author

@repeatedly @edsiper @tianon: what's blocking this currently?

@runningman84
Copy link

@lag-linaro do you have some build already published somewhere? I have a mixed k8s env with amd64/arm64 and would be happy to test if I can deploy it with the same daemonset...

I can push a build for you if it helps?

yes a multiarch image in docker hub would help...

@repeatedly
Copy link
Member

No blocker for patch itself.
We need to change tag format before because it may break existing environment and it shouldn't.

#159

@lag-linaro
Copy link
Contributor Author

@lag-linaro do you have some build already published somewhere? I have a mixed k8s env with amd64/arm64 and would be happy to test if I can deploy it with the same daemonset...

I can push a build for you if it helps?

yes a multiarch image in docker hub would help...

It's not multi-arch (no images are), but here is an aarch64 (arm64, armv8) one for you:

https://hub.docker.com/r/laglinaro/fluentd-v1.3-aarch64/

To pull it on your AArch64 based platform use:

docker pull laglinaro/fluentd-v1.3-aarch64

@lag-linaro
Copy link
Contributor Author

No blocker for patch itself.
We need to change tag format before because it may break existing environment and it shouldn't.

#159

Understood. Do you know when this might be resolved?

@repeatedly repeatedly mentioned this pull request Dec 18, 2018
@repeatedly
Copy link
Member

I just merged #161
So ready to merge this patch.

@lag-linaro
Copy link
Contributor Author

Wonderful. Do you know when it will be done?

@repeatedly
Copy link
Member

@lag-linaro Could you resolve the conflict?
master's fluentd version is v1.3.2 so need to merge master change.

@lag-linaro
Copy link
Contributor Author

@lag-linaro Could you resolve the conflict?
master's fluentd version is v1.3.2 so need to merge master change.

Yes, I'll do that right away.

Lee Jones added 8 commits December 19, 2018 11:46
Note that we can't convert Alpine ARMHF images, as they are not pushed to Docker Hub.

This issue was highlighted by @tianon

  LINK: fluent#152 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
As suggested by @tianon

  LINK: docker-library/official-images#3724 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
As suggested by @tianon

  LINK: docker-library/official-images#3724 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
The FluentD package does not provide a 'fluent' user.  Until now
hacks exist in the entrypoint.sh which provide one manually at
run-time.  Instead of doing that, let's create the user when the
container is created.

This issue was highlighted by @tianon

  LINK: docker-library/official-images#3724 (comment)

Signed-off-by: Lee Jones <[email protected]>
If permissions problems exist, they should be overcome properly.

For examples see:

  LINK: docker-library/rabbitmq#60
  LINK: docker-library/cassandra#48
  LINK: docker-library/mongo#81
  LINK: redis/docker-library-redis#48
  LINK: docker-library/mysql#161
  LINK: MariaDB/mariadb-docker#59
  LINK: docker-library/percona#21
  LINK: docker-library/ghost#54
  LINK: docker-library/postgres#253

As suggested by @tianon

  LINK: docker-library/official-images#3724 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
This allows us to remove the `FLUENTD_CONF` and `FLUENTD_OPT` envs.

As suggested by @tianon

  LINK: docker-library/official-images#3724 (comment)

This is part of an effort to make FluentD part of Docker's Official Images.

Signed-off-by: Lee Jones <[email protected]>
@lag-linaro lag-linaro force-pushed the convert-to-docker-official-images branch from da77e14 to 223e5fa Compare December 19, 2018 11:56
@lag-linaro lag-linaro force-pushed the convert-to-docker-official-images branch from 223e5fa to 5896b1e Compare December 19, 2018 12:14
@repeatedly repeatedly merged commit d5b7782 into fluent:master Dec 20, 2018
@lag-linaro
Copy link
Contributor Author

Awesome.

Will you be submitting the change to Docker's Official Images repo?

An updated version of this PR: docker-library/official-images#3724

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants