Merge ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master

Proposed by Scott Moser
Status: Rejected
Rejected by: Scott Moser
Proposed branch: ~smoser/cloud-init:fix/1134036-locale-message-change
Merge into: cloud-init:master
Diff against target: 92 lines (+19/-32)
1 file modified
tools/Z99-cloud-locale-test.sh (+19/-32)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Needs Fixing
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+348065@code.launchpad.net

Commit message

Z99-cloud-locale-test.sh: shorten message and change locale to C.UTF-8.

Two basic changes here to the behavior of Z99-cloud-locale-test.sh
when a locale found in LC_* settings is not present on the system:

a.) shorten the message.
b.) change the locale to C.UTF-8.

LP: #1134036

Description of the change

This can be tested with:
$ rm -f ~/.cloud-locale-test.skip
$ LC_ALL=fr_FR.UTF-8 sh ./tools/Z99-cloud-locale-test.sh

The message shown at this point is:

| Your provided locale (LC_ALL=fr_FR.UTF-8) is not available and has been
| changed to C.UTF-8 (LC_ALL=C.UTF-8). To install native locales:
| sudo apt-get install locales language-pack-fr

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:4d94c6f9cb1a244997634399547137d5cd868d2c
https://jenkins.ubuntu.com/server/job/cloud-init-ci/92/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/92/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:8ad644088052baad0e3db31a632dba45b1aec605
https://jenkins.ubuntu.com/server/job/cloud-init-ci/93/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: MAAS Compatability Testing
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/93/rebuild

review: Approve (continuous-integration)
Revision history for this message
Steve Langasek (vorlon) wrote :

From https://bugs.launchpad.net/ubuntu/+source/maas/+bug/1134036/comments/20, this addresses the first point (no broken locale at login), but not the second or third points (no banner message for English locale requested; no banner message on minimal images). Are you disagreeing with those points, or is this just not implemented yet as part of this MP?

Revision history for this message
Scott Moser (smoser) wrote :

Steve,

Of the 4 points addressed, I think that I addressed
a.) set LC_ALL=C.UTF-8 - this is done

b.) a long message - i shortened the message dramatically.

c.) do not show in minimal images - this is not addressed.
I'm not sure how we would address this. I'd prefer that cloud-init not have specific "This is a Canonical authored Ubuntu minimal image" code, so I'd like some generic mechanism to determine that. I'd appreciate any suggestions on how to do that.

d.) limited value of english message.
I generally disagree here, and suggest that it is "good enough" and better than silently changing user's environment variables. As you said "the vast majority of actual Ubuntu Server users are comfortable navigating a CLI in English even if it is not their first language."

I really don't want to spend much time on this. I'm not particularly convinced that the arguments in the bug warrant a change in behavior for all users, and I would not personally want to justify this behavioral change in a SRU. That puts me in the annoying position of having to maintain patches to prior Ubuntu stable releases.

So... I'm perfectly fine if you want to take over from here. I had this code open and thought I'd try to improve the situation a bit.

Revision history for this message
Steve Langasek (vorlon) wrote :

Improving the situation "a bit" does not address my concerns. As long as users of client-side English locales have such a message taking up any real estate at login, I consider this unresolved. From our discussion and the git history I don't see any evidence that this was subject to any sort of high-level design review when it was added; I don't think it's appropriate to have a higher barrier for its removal.

If you are concerned about not hard-coding implementation details of Ubuntu minimal images into this script, then the simplest way to address is to remove the warning message unconditionally. This would be consistent with the long-term design goals for openssh.

review: Disapprove
Revision history for this message
Steve Langasek (vorlon) wrote :

technical review of the changes, inline:

review: Needs Fixing
Revision history for this message
Scott Moser (smoser) wrote :

> Improving the situation "a bit" does not address my concerns. As long as
> users of client-side English locales have such a message taking up any real
> estate at login, I consider this unresolved. From our discussion and the git
> history I don't see any evidence that this was subject to any sort of high-
> level design review when it was added; I don't think it's appropriate to have
> a higher barrier for its removal.

Why do you think this is a "higher barrier"? We don't make *any* changes
to code without consideration. That is just generally accepted practice.
Changes that are user-facing do have higher barrier, and they do in
the ubuntu Stable Release Process as well.

>
> If you are concerned about not hard-coding implementation details of Ubuntu
> minimal images into this script, then the simplest way to address is to remove
> the warning message unconditionally. This would be consistent with the long-
> term design goals for openssh.

You linked to an upstream ssh bug opened over 10 years ago, with the last
comment made over 5 years ago. What do you consider "long-term" ?
Do you have some reason to believe that all of a sudden someone will change
that? Would you expect that that user-facing change would then be SRU'd
in ubuntu ?

Revision history for this message
Scott Moser (smoser) wrote :

I'll mark this "work in progress." This is probably all the effort I'll put forth on a fix. Feel free to submit your own solution for review.

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh
2index 4978d87..050ee76 100644
3--- a/tools/Z99-cloud-locale-test.sh
4+++ b/tools/Z99-cloud-locale-test.sh
5@@ -6,9 +6,8 @@
6 # (c) 2012, Canonical Group, Ltd.
7 #
8 # This file is part of cloud-init. See LICENSE file for license information.
9-
10-# Purpose: Detect invalid locale settings and inform the user
11-# of how to fix them.
12+
13+# Purpose: Detect invalid locale, change to C-UTF-8. and inform the user.
14
15 locale_warn() {
16 local bad_names="" bad_lcs="" key="" val="" var="" vars="" bad_kv=""
17@@ -33,6 +32,10 @@ locale_warn() {
18 vars="${vars} $key=$val";;
19 esac
20 done
21+
22+ if [ "${bad_names#* LC_ALL}" != "${bad_names}" ]; then
23+ bad_names=LC_ALL
24+ fi
25 for bad in $bad_names; do
26 for var in ${vars}; do
27 [ "${bad}" = "${var%=*}" ] || continue
28@@ -47,14 +50,7 @@ locale_warn() {
29 bad_kv=${bad_kv# }
30 [ -n "$bad_lcs" ] || return 0
31
32- printf "_____________________________________________________________________\n"
33- printf "WARNING! Your environment specifies an invalid locale.\n"
34- printf " The unknown environment variables are:\n %s\n" "$bad_kv"
35- printf " This can affect your user experience significantly, including the\n"
36- printf " ability to manage packages. You may install the locales by running:\n\n"
37-
38- local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
39- local pkgs=""
40+ local bad="" pkgs="" invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
41 if [ -e "$sfile" ]; then
42 for bad in ${bad_lcs}; do
43 grep -q -i "${bad}" "$sfile" &&
44@@ -62,7 +58,6 @@ locale_warn() {
45 invalid="${invalid} ${bad}"
46 done
47 else
48- printf " sudo apt-get install locales\n"
49 to_gen=$bad_lcs
50 fi
51 to_gen=${to_gen# }
52@@ -73,28 +68,20 @@ locale_warn() {
53 done
54 pkgs=${pkgs# }
55
56- if [ -n "${pkgs}" ]; then
57- printf " sudo apt-get install ${pkgs# }\n"
58- printf " or\n"
59- printf " sudo locale-gen ${to_gen# }\n"
60- printf "\n"
61- fi
62- for bad in ${invalid}; do
63- printf "WARNING: '${bad}' is an invalid locale\n"
64- done
65-
66- printf "To see all available language packs, run:\n"
67- printf " apt-cache search \"^language-pack-[a-z][a-z]$\"\n"
68- printf "To disable this message for all users, run:\n"
69- printf " sudo touch /var/lib/cloud/instance/locale-check.skip\n"
70- printf "_____________________________________________________________________\n\n"
71-
72- # only show the message once
73- : > ~/.cloud-locale-test.skip 2>/dev/null || :
74+ echo "Your provided locale (${bad_kv}) is not available and has been"
75+ echo "changed to C.UTF-8 (LC_ALL=C.UTF-8). To install native locales:"
76+ echo " sudo apt-get install locales${pkgs:+ ${pkgs}}"
77+ return 1
78 }
79
80-[ -f ~/.cloud-locale-test.skip -o -f /var/lib/cloud/instance/locale-check.skip ] ||
81- locale 2>&1 | locale_warn
82+if [ ! -f ~/.cloud-locale-test.skip ] &&
83+ [ ! -f /var/lib/cloud/instance/locale-check.skip ]; then
84+ if locale 2>&1 | locale_warn; then
85+ LC_ALL=C.UTF-8
86+ # only show the message once
87+ : > ~/.cloud-locale-test.skip 2>/dev/null || :
88+ fi
89+fi
90
91 unset locale_warn
92 # vi: ts=4 expandtab

Subscribers

People subscribed via source and target branches