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

Test for working en_US.UTF-8 locale #108

Merged
merged 12 commits into from
Jul 11, 2019
Merged

Conversation

mbargull
Copy link
Member

@mbargull mbargull commented Jul 3, 2019

Do we really need the changes from gh-83 and gh-97?
It seems like CentOS/sig-cloud-instance-images#71 is a resolved issue and the locale is working, isn't it?
I'd rather like us to test whether the locale is working and only apply fixes if it really is not.
I couldn't find a reference to a recent issue in gh-83. @mariusvniekerk, @hmaarrfk, can you point me to failing cases such that we can incorporate them in the tests?

Also, @mariusvniekerk, gh-83 has been for aarch64 only. The only significant difference to ppc64le I could find is that aarch64 does not have CentOS/sig-cloud-instance-build@2892c17#diff-574fa022ad7d0be565da139e942a15cbR92 , i.e., it has override_install_langs=en_US.UTF-8 in /etc/yum.conf instead of en_US.utf8. If that is the culprit, we should change that (and upstream it, of course).

@@ -2,6 +2,12 @@

set -xeuo pipefail

# test for working en_US.UTF-8 locale
locale -a | grep -i 'en_US.UTF.\?8'
[ "$( LC_ALL=en_US.UTF-8 sh -euc : 2>&1 )" = "" ]
Copy link
Member Author

Choose a reason for hiding this comment

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

This would spit out

/usr/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory

on stderr if the locale wouldn't work. If it works, we just get no output and can test for that.

@mbargull
Copy link
Member Author

mbargull commented Jul 3, 2019

The only significant difference to ppc64le I could find is that aarch64 does not have CentOS/sig-cloud-instance-build@2892c17#diff-574fa022ad7d0be565da139e942a15cbR92 , i.e., it has override_install_langs=en_US.UTF-8 in /etc/yum.conf instead of en_US.utf8. If that is the culprit, we should change that (and upstream it, of course).

Yep, that was is. All fixed now. I'll open an upstream PR.

@mbargull
Copy link
Member Author

mbargull commented Jul 3, 2019

I'll open an upstream PR.

xref: CentOS/sig-cloud-instance-build#154

@mbargull mbargull marked this pull request as ready for review July 3, 2019 19:01
@@ -38,7 +30,14 @@ RUN yum update -y && \
sudo \
tar \
which && \
yum clean all
: '(centos:6 only) If glibc-common is updated, we have to manually purge non-en_US locales.' && \
Copy link
Member Author

Choose a reason for hiding this comment

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

Docker doesn't like real comments as part of a multi-line RUN so we have to work around that if we want them.
(Ab-)using the null utility (special built-in) : for this is a little hacky, TBH, but it really doesn't do any harm, so it is perfectly fine in my book.

Copy link
Member

Choose a reason for hiding this comment

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

Could we move this out into a bash script that we add and run to all Dockerfiles? This will ensure we only need to update and maintain this in one spot (as opposed to every Docker image), which will keep things maintainable here. Also we can format this more nicely without having to deal with Docker's syntax oddities. 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I had the same thing in mind. I was just in the "meh, I'll likely refactor stuff later anyway when proposing multi-staged builds, so whatever" state 😉 .

Copy link
Member Author

Choose a reason for hiding this comment

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

Now it uses a common script in all images so that the rm -rf /var/cache/yum/* addition is only in one place, too.

@mbargull
Copy link
Member Author

mbargull commented Jul 4, 2019

This is good to go, please take a look.
What this does:

  • add tests for working locale
  • properly fix the aarch64 locale issue (write override_install_langs=en_US.utf8 to /etc/yum.conf)
  • properly rebuilt locale archive on centos:6 (removes ~ 90 MiB)
  • clean caches more thoroughly (i.e., conda clean -i and rm -rf /var/cache/yum/*)
  • add missing GPG keys for RPM on aarch64 and ppc64le
  • show docker history when testing (can be used to inspect layer sizes if --squash is (temporarily) disabled)

locale -a | grep -i 'en_US.UTF.\?8'
[ "$( LC_ALL=en_US.UTF-8 sh -euc : 2>&1 )" = "" ]
# make sure the above fails for non-existent locale
[ ! "$( LC_ALL=badlocale sh -euc : 2>&1 )" = "" ]
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@hmaarrfk
Copy link
Contributor

hmaarrfk commented Jul 4, 2019

Looks pretty good, but I'm no expert :/

@mbargull
Copy link
Member Author

mbargull commented Jul 4, 2019

Oh, and apart from testing/fixing the locale, this also shrinks the (squashed, uncompressed) -comp7 image by ~ 30 % (total 1.28 GB vs 1.82 GB total or 1.08 GB vs 1.63 GB for the layers we add).

@mbargull
Copy link
Member Author

mbargull commented Jul 4, 2019

Thanks for the review @hmaarrfk!

@@ -2,6 +2,12 @@

set -xeuo pipefail

# test for working en_US.UTF-8 locale
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some echo messages here so that is is clear in the logs what is actually going on here? Mostly just a line saying validate utf8 locale configured correctly.

(Also remove unused '-eu' in 'sh -c' call)
@@ -2,6 +2,12 @@

set -xeuo pipefail

echo 'Validating correctly configured en_US.UTF-8 locale...'
Copy link
Member Author

Choose a reason for hiding this comment

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

@mariusvniekerk, like so?

Copy link
Member

@mariusvniekerk mariusvniekerk left a comment

Choose a reason for hiding this comment

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

LGTM

# (centos:6 only) If glibc-common is updated, we have to manually purge non-en_US locales.
if grep -F 'CentOS release 6' /etc/centos-release ; then
if locale -a | grep nds_DE ; then
cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
Copy link
Member Author

Choose a reason for hiding this comment

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

(cp instead of mv to avoid writing to the mmapped file later.)

Copy link
Member

Choose a reason for hiding this comment

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

Should we make that a comment in the script?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, not really important. The only change I expect to happen to this code is to be removed whenever this isn't needed anymore, e.g., when we use Centos 7 everywhere.
I just added the comment for my future self if I ever wondered why I changed that.

@mbargull
Copy link
Member Author

mbargull commented Jul 8, 2019

This would be ready to merge. However, Travis didn't run somehow... Any ideas?

@mbargull
Copy link
Member Author

mbargull commented Jul 8, 2019

Travis is running. But it's not listed as one of the "checks" needed. Strange.

RUN yum update -y && \
yum install -y \
bzip2 \
sudo \
tar \
which && \
yum clean all && \
rm -rf /var/cache/yum/*
/opt/docker/bin/yum_clean_all
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should just move all of this into that script.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this and other parts can/should be consolidated. But let's do further cleanup.maintenance work later, not in this PR.

@mbargull
Copy link
Member Author

mbargull commented Jul 8, 2019

Travis build finished.... and is listed as "Pending — The Travis CI build is in progress"... right... Well, ready to merge from my side.

@mariusvniekerk
Copy link
Member

If you really want the full green orb treatment you may want to restart the Travis build. I don't care too much about that :)

@mbargull
Copy link
Member Author

mbargull commented Jul 9, 2019

the full green orb treatment

Oh, I like many kinds of green hues -- olive green is a nice one; all good ;).
I was just waiting for John's nod. @jakirkham, you okay with the current state and postponing further cleanup and such?

@mbargull mbargull merged commit de11f43 into conda-forge:master Jul 11, 2019
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.

4 participants