canonical / microk8s

MicroK8s is a small, fast, single-package Kubernetes for datacenters and the edge.
https://microk8s.io
Apache License 2.0
8.52k stars 773 forks source link

microk8s locale error on centos 7. The exported locale is "C.UTF-8" but it is not supported #3760

Closed ebebpl closed 9 months ago

ebebpl commented 1 year ago

Summary

microk8s wont start on Centos 7.9 and gives an error: 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: File "/snap/microk8s/4595/usr/lib/python3/dist-packages/click/_unicodefun.py", line 118, in _verify_python3_env 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: Click discovered that you exported a UTF-8 locale 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: but the locale system could not pick up from it because 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: it does not exist. The exported locale is "C.UTF-8" but it 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: is not supported

$ snap --version snap 2.57.6-2.el7 snapd 2.57.6-2.el7 series 16 centos 7 kernel 3.10.0-1160.81.1.el7.x86_64

$ microk8s version MicroK8s v1.26.1 revision 4595

What Should Happen Instead?

microk8s should start without locale errors.

Reproduction Steps

  1. $ microk8s start
  2. $ snap logs microk8s

2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: File "/snap/microk8s/4595/usr/lib/python3/dist-packages/click/_unicodefun.py", line 118, in _verify_python3_env 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: 'for mitigation steps.' + extra) 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult http://click.pocoo.org/python3/for mitigatioteps. 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: This system lists a couple of UTF-8 supporting locales that 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: you can pick from. The following suitable locales where 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: discovered: aa_DJ.utf8, aa_ER.utf8, aa_ET.utf8, af_ZA.utf8, am_ET.utf8, an_ES.utf8, ar_AE.utf8, ar_BH.utf8, ar_DZ.utf8, ar_EG.utf8, ar_IN.utf8, ar_IQ.utf8, ar_JO.utf8, ar_KW.utf8, LB.utf8, ar_LY.utf8, ar_MA.utf8, ar_OM.utf8, ar_QA.utf8, ar_SA.utf8, ar_SD.utf8, ar_SY.utf8, ar_TN.utf8, ar_YE.utf8, as_IN.utf8, ast_ES.utf8, ayc_PE.utf8, az_AZ.utf8, be_BY.utf8, bem_ZM.utf8, ber_DZ.utf8, ber_MA.utf8, bg_BG.utf8, bho_IN.utf8, bn_Btf8, bn_IN.utf8, bo_CN.utf8, bo_IN.utf8, br_FR.utf8, brx_IN.utf8, bs_BA.utf8, byn_ER.utf8, ca_AD.utf8, ca_ES.utf8, ca_FR.utf8, ca_IT.utf8, crh_UA.utf8, cs_CZ.utf8, csb_PL.utf8, cv_RU.utf8, cy_GB.utf8, da_DK.utf8, de_AT.utf8, de_BE.utf8, de_CH.utf8e_DE.utf8, de_LU.utf8, doi_IN.utf8, dv_MV.utf8, dz_BT.utf8, el_CY.utf8, el_GR.utf8, en_AG.utf8, en_AU.utf8, en_BW.utf8, en_CA.utf8, en_DK.utf8, en_GB.utf8, en_HK.utf8, en_IE.utf8, en_IN.utf8, en_NG.utf8, en_NZ.utf8, en_PH.utf8, en_SG.utf8, en_US.u, en_ZA.utf8, en_ZM.utf8, en_ZW.utf8, es_AR.utf8, es_BO.utf8, es_CL.utf8, es_CO.utf8, es_CR.utf8, es_CU.utf8, es_DO.utf8, es_EC.utf8, es_ES.utf8, es_GT.utf8, es_HN.utf8, es_MX.utf8, es_NI.utf8, es_PA.utf8, es_PE.utf8, es_PR.utf8, es_PY.utf8, es_SVf8, es_US.utf8, es_UY.utf8, es_VE.utf8, et_EE.utf8, eu_ES.utf8, fa_IR.utf8, ff_SN.utf8, fi_FI.utf8, fil_PH.utf8, fo_FO.utf8, fr_BE.utf8, fr_CA.utf8, fr_CH.utf8, fr_FR.utf8, fr_LU.utf8, fur_IT.utf8, fy_DE.utf8, fy_NL.utf8, ga_IE.utf8, gd_GB.utf8, gER.utf8, gez_ET.utf8, gl_ES.utf8, gu_IN.utf8, gv_GB.utf8, ha_NG.utf8, he_IL.utf8, hi_IN.utf8, hne_IN.utf8, hr_HR.utf8, hsb_DE.utf8, ht_HT.utf8, hu_HU.utf8, hy_AM.utf8, ia_FR.utf8, id_ID.utf8, ig_NG.utf8, ik_CA.utf8, is_IS.utf8, it_CH.utf8, it_IT.u, iu_CA.utf8, iw_IL.utf8, ja_JP.utf8, ka_GE.utf8, kk_KZ.utf8, kl_GL.utf8, km_KH.utf8, kn_IN.utf8, ko_KR.utf8, kok_IN.utf8, ks_IN.utf8, ku_TR.utf8, kw_GB.utf8, ky_KG.utf8, lb_LU.utf8, lg_UG.utf8, li_BE.utf8, li_NL.utf8, lij_IT.utf8, lo_LA.utf8, lt_utf8, lv_LV.utf8, mag_IN.utf8, mai_IN.utf8, mg_MG.utf8, mhr_RU.utf8, mi_NZ.utf8, mk_MK.utf8, ml_IN.utf8, mn_MN.utf8, mni_IN.utf8, mr_IN.utf8, ms_MY.utf8, mt_MT.utf8, my_MM.utf8, nb_NO.utf8, nds_DE.utf8, nds_NL.utf8, ne_NP.utf8, nhn_MX.utf8, niu_NUf8, niu_NZ.utf8, nl_AW.utf8, nl_BE.utf8, nl_NL.utf8, nn_NO.utf8, nr_ZA.utf8, nso_ZA.utf8, oc_FR.utf8, om_ET.utf8, om_KE.utf8, or_IN.utf8, os_RU.utf8, pa_IN.utf8, pa_PK.utf8, pap_AN.utf8, pl_PL.utf8, ps_AF.utf8, pt_BR.utf8, pt_PT.utf8, ro_RO.utf8, RU.utf8, ru_UA.utf8, rw_RW.utf8, sa_IN.utf8, sat_IN.utf8, sc_IT.utf8, sd_IN.utf8, se_NO.utf8, shs_CA.utf8, si_LK.utf8, sid_ET.utf8, sk_SK.utf8, sl_SI.utf8, so_DJ.utf8, so_ET.utf8, so_KE.utf8, so_SO.utf8, sq_AL.utf8, sq_MK.utf8, sr_ME.utf8, sr_RS.u, ss_ZA.utf8, st_ZA.utf8, sv_FI.utf8, sv_SE.utf8, sw_KE.utf8, sw_TZ.utf8, szl_PL.utf8, ta_IN.utf8, ta_LK.utf8, te_IN.utf8, tg_TJ.utf8, th_TH.utf8, ti_ER.utf8, ti_ET.utf8, tig_ER.utf8, tk_TM.utf8, tl_PH.utf8, tn_ZA.utf8, tr_CY.utf8, tr_TR.utf8, ts_utf8, tt_RU.utf8, ug_CN.utf8, uk_UA.utf8, unm_US.utf8, ur_IN.utf8, ur_PK.utf8, ve_ZA.utf8, vi_VN.utf8, wa_BE.utf8, wae_CH.utf8, wal_ET.utf8, wo_SN.utf8, xh_ZA.utf8, yi_US.utf8, yo_NG.utf8, yue_HK.utf8, zh_CN.utf8, zh_HK.utf8, zh_SG.utf8, zh_TW.utfzu_ZA.utf8 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: Click discovered that you exported a UTF-8 locale 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: but the locale system could not pick up from it because 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: it does not exist. The exported locale is "C.UTF-8" but it 2023-02-15T14:50:11-05:00 microk8s.daemon-apiserver-kicker[26946]: is not supported

Introspection Report

$ microk8s inspect Inspecting system Inspecting Certificates Inspecting services Service snap.microk8s.daemon-cluster-agent is running Service snap.microk8s.daemon-containerd is running FAIL: Service snap.microk8s.daemon-kubelite is not running For more details look at: sudo journalctl -u snap.microk8s.daemon-kubelite Service snap.microk8s.daemon-k8s-dqlite is running Service snap.microk8s.daemon-apiserver-kicker is running Copy service arguments to the final report tarball Inspecting AppArmor configuration Gathering system information Copy processes list to the final report tarball Copy disk usage information to the final report tarball Copy memory usage information to the final report tarball Copy server uptime to the final report tarball Copy openSSL information to the final report tarball Copy snap list to the final report tarball Copy VM name (or none) to the final report tarball Copy current linux distribution to the final report tarball Copy network configuration to the final report tarball Inspecting kubernetes cluster Inspect kubernetes cluster Inspecting dqlite Inspect dqlite

WARNING: Please ensure br_netfilter kernel module is loaded on the host. Building the report tarball

Can you suggest a fix?

Are you interested in contributing with a fix?

ktsakalozos commented 1 year ago

Hi @ebebpl would it be possible to set a global locale?

As you can see in [1] we try to use the $LC_ALL and $LANG environment variables of the system but if we don't find them set we default to C.UTF-8. Could you try to set these variables? I suspect you could append in /etc/environment:

export LC_ALL="en_GB.UTF-8"
export LANG="en_GB.UTF-8"

... and then reboot

[1] https://github.com/canonical/microk8s/blob/master/microk8s-resources/wrappers/run-kubelite-with-args#L9

ebebpl commented 1 year ago

Thanks @ktsakalozos it worked after adding the below variables to /etc/environment and logoff/logon as root. Reboot was not needed.
$ cat /etc/environment LANG=en_US.utf8 LC_ALL=en_US.utf8

I also saw in this blog https://wiki.archlinux.org/title/locale#Generating_locales so I think LC_ALL is usually blank in Centos 7 so it impacts the kubelite shell script. LCALL: troubleshooting The locale set for this variable will always override LANG and all the other LC variables, whether they are set or not. If LC_ALL is set to C, it will also override LANGUAGE. LCALL is the only LC variable which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile.

stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.