Closed heitorPB closed 2 years ago
I tried to check the status of one of our charms, but charmcraft crashes:
$ charmcraft status prometheus-node-exporter
Not logged in.
Full execution log: '/home/h/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220214-104832.741064.log'
$ cat /home/h/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220214-104832.741064.log
2022-02-14 10:48:32.741 Starting charmcraft version 1.4.0
2022-02-14 10:48:32.741 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'trace': False, 'project_dir': None} filtered=['status', 'prometheus-node-exporter']
2022-02-14 10:48:32.741 General parsed sysargs: command='status' args=['prometheus-node-exporter']
2022-02-14 10:48:32.743 Command parsed sysargs: Namespace(name='prometheus-node-exporter')
2022-02-14 10:48:32.782 Retrieving credentials for 'charmcraft' on HttpUrl('https://api.charmhub.io', scheme='https', host='api.charmhub.io', tld='io', host_type='domain') from keyring 'auth MemoryKeyring'.
2022-02-14 10:48:32.782 Credentials not found in the keyring 'auth MemoryKeyring'
2022-02-14 10:48:32.782 Not logged in.
2022-02-14 10:48:32.783 Traceback (most recent call last):
2022-02-14 10:48:32.783 File "/snap/charmcraft/761/lib/charmcraft/commands/store/client.py", line 94, in request_urlpath_json
2022-02-14 10:48:32.783 response = super().request(method, self.api_base_url + urlpath, *args, **kwargs)
2022-02-14 10:48:32.783 File "/snap/charmcraft/761/lib/craft_store/base_client.py", line 151, in request
2022-02-14 10:48:32.783 headers["Authorization"] = self._get_authorization_header()
2022-02-14 10:48:32.783 File "/snap/charmcraft/761/lib/craft_store/store_client.py", line 96, in _get_authorization_header
2022-02-14 10:48:32.783 auth = self._auth.get_credentials()
2022-02-14 10:48:32.783 File "/snap/charmcraft/761/lib/craft_store/auth.py", line 150, in get_credentials
2022-02-14 10:48:32.783 raise errors.NotLoggedIn()
2022-02-14 10:48:32.783 craft_store.errors.NotLoggedIn: Not logged in.
2022-02-14 10:48:32.783 Full execution log: '/home/h/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220214-104832.741064.log'
There is something very weird going on:
$ charmcraft login
Opening an authorization web page in your browser.
If it does not open, please open this URL:
https://api.jujucharms.com/identity/login?did=455ef7f55578958436af31a854d656a4a649273a7892c0068b705c15b2a5af58
Logged in as 'omnivector-solutions'.
$ charmcraft upload --release=edge prometheus-node-exporter_ubuntu-20.04-amd64_centos-7-amd64.charm
Credentials not found. Trying to log in... Opening an authorization web page in your browser.
If it does not open, please open this URL:
https://api.jujucharms.com/identity/login?did=254c1db18fb107f11d179b89d2b522dea36dd3e4c619ce754ee61e6dc392751c
Revision 4 of 'prometheus-node-exporter' created
Revision released to edge
$ charmcraft whoami
You are not logged in to Charmhub.
It appears that charmcraft
is not storing the login data after any command completes.
Using charmcraft 1.4.0 from latest/stable
A segunda-feira, 14 de fevereiro de 2022 16:28:14 -03 Heitor escreveu:
There is something very weird going on:
$ charmcraft login Opening an authorization web page in your browser. If it does not open, please open this URL: https://api.jujucharms.com/identity/login?did=455ef7f55578958436af31a854d65 6a4a649273a7892c0068b705c15b2a5af58 Logged in as 'omnivector-solutions'. $ charmcraft upload --release=edge prometheus-node-exporter_ubuntu-20.04-amd64_centos-7-amd64.charm Credentials not found. Trying to log in... Opening an authorization web page in your browser. If it does not open, please open this URL: https://api.jujucharms.com/identity/login?did=254c1db18fb107f11d179b89d2b52 2dea36dd3e4c619ce754ee61e6dc392751c Revision 4 of 'prometheus-node-exporter' created Revision released to edge $ charmcraft whoami You are not logged in to Charmhub.
It appears that
charmcraft
is not storing the login data after any command completes.Using charmcraft 1.4.0 from latest/stable
The latest charmcraft from edge has a better message when running on systems without a keyring.
I do have a keyring on my systems. But what does it have to do with charmcraft? Is this issue fixed on edge channel? When can we expect a new charmcraft release with this fix?
Hello @heitorPB !
In which system are you running this? And how did you install charmcraft?
Thanks!
Ubuntu 20.04 LTS
Installed like sudo snap install charmcraft
(i don't remember if it needs the --classic
flag)
Does it work if you --export
the auth?
Mmm... so strange, the keyring should be found.
Would you please run this and pass the logs? Thanks!
charmcraft login --trace
Thanks!
$ charmcraft login --trace
2022-02-17 10:38:32.957 Starting charmcraft version 1.4.0
2022-02-17 10:38:32.957 Logging execution to '/home/h/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220217-103832.953318.log'
2022-02-17 10:38:32.957 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'trace': True, 'project_dir': None} filtered=['login']
2022-02-17 10:38:32.957 General parsed sysargs: command='login' args=[]
2022-02-17 10:38:32.957 Couldn't find config file '/home/h/charmcraft.yaml'
2022-02-17 10:38:32.958 Command parsed sysargs: Namespace(bundle=None, channel=None, charm=None, export=None, permission=None, ttl=None)
2022-02-17 10:38:33.039 HTTP 'POST' for 'https://api.charmhub.io/v1/tokens' with params None and headers {'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'charmcraft/1.4.0 ubuntu/20.04 (x86_64) python/3.8.10'} | (2.2s) Opening an authorization web page in your browser.
If it does not open, please open this URL:
https://api.jujucharms.com/identity/login?did=2a317a2c58dbd43016250d9870213b88cd220a3bd0b7c7887c9b26ffde117cbf
2022-02-17 10:38:33.039 HTTP 'POST' for 'https://api.charmhub.io/v1/tokens' with params None and headers {'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'charmcraft/1.4.0 ubuntu/20.04 (x86_64) python/3.8.10'}
2022-02-17 10:38:35.326 HTTP 'GET' for 'https://api.jujucharms.com/identity/wait-token?did=2a317a2c58dbd43016250d9870213b88cd220a3bd0b7c7887c9b26ffde117cbf' with params None and headers {'User-Agent': 'charmcraft/1.4.0 ubuntu/20.04 (x86_64) python/3.8.10'}
2022-02-17 10:38:58.796 HTTP 'POST' for 'https://api.charmhub.io/v1/tokens/exchange' with params None and headers {'Macaroons': '<macaroon>', 'User-Agent': 'charmcraft/1.4.0 ubuntu/20.04 (x86_64) python/3.8.10'}
2022-02-17 10:38:59.727 Storing credentials for 'charmcraft' on HttpUrl('https://api.charmhub.io', scheme='https', host='api.charmhub.io', tld='io', host_type='domain') in keyring 'auth MemoryKeyring'.
2022-02-17 10:38:59.727 Retrieving credentials for 'charmcraft' on HttpUrl('https://api.charmhub.io', scheme='https', host='api.charmhub.io', tld='io', host_type='domain') from keyring 'auth MemoryKeyring'.
2022-02-17 10:38:59.727 HTTP 'GET' for 'https://api.charmhub.io/v1/tokens/whoami' with params None and headers {'Authorization': '<macaroon>', 'User-Agent': 'charmcraft/1.4.0 ubuntu/20.04 (x86_64) python/3.8.10'}
Logged in as 'omnivector-solutions'.
$ charmcraft whoami --trace
2022-02-17 10:40:56.202 Starting charmcraft version 1.4.0
2022-02-17 10:40:56.202 Logging execution to '/home/h/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220217-104056.201777.log'
2022-02-17 10:40:56.202 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'trace': True, 'project_dir': None} filtered=['whoami']
2022-02-17 10:40:56.202 General parsed sysargs: command='whoami' args=[]
2022-02-17 10:40:56.202 Couldn't find config file '/home/h/charmcraft.yaml'
2022-02-17 10:40:56.203 Command parsed sysargs: Namespace()
2022-02-17 10:40:56.239 Retrieving credentials for 'charmcraft' on HttpUrl('https://api.charmhub.io', scheme='https', host='api.charmhub.io', tld='io', host_type='domain') from keyring 'auth MemoryKeyring'.
2022-02-17 10:40:56.239 Credentials not found in the keyring 'auth MemoryKeyring'
You are not logged in to Charmhub.
If charmcraft is now using an external keyring, what are the ones supported?
Does it work if you
--export
the auth?
It works if I export and set the env var. But doesn't feel like a proper solution... If charmcraft can't find a keyring, it shouldn't try to use one, instead should use the old auth method.
@heitorPB @facundobatista Do we know of a timeframe for a bug fix release with a fix that addresses this issue?
Charmcraft is not finding a suitable keyring in your system, so it's fallbacking to a MemoryRing, which actually does not really store anything (it was a bug that it did that silently, it's already fixed and louder).
In any way, the real problem is why a keyring is not found. For further analysis, I'd need for you to issue the following commands and show results, please:
lsb_release -a
uname -a
echo $DESKTOP_SESSION
echo $XDG_CURRENT_DESKTOP
Thanks!
On Tue, 22 Feb 2022 04:02:22 -0800 Facundo Batista @.***> wrote:
Charmcraft is not finding a suitable keyring in your system, so it's fallbacking to a MemoryRing, which actually does not really store anything (it was a bug that it did that silently, it's already fixed and louder).
Aah, got it. Is there any plan to release a fixed Charmcraft soon?
In any way, the real problem is why a keyring is not found.
This is my current setup: a remote server running Ubuntu 20.04 Server LTS, headless, with all Juju-related stuff.
My keyring is on my laptop, and keys are forwarded via SSH to the software that needs it.
For further analysis, I'd need for you to issue the following commands and show results, please:
lsb_release -a uname -a echo $DESKTOP_SESSION echo $XDG_CURRENT_DESKTOP
Here it is:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
$ uname -a
Linux valkyrien 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29
UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ echo $DESKTOP_SESSION
$ echo $XDG_CURRENT_DESKTOP
Ah, a remote system. So yes, you need to export the credentials and pass them through a environment variable.
I'm not sure if it's actually possible to "forward the keyring through SSH", but for sure it's not working in your case. Note that "ssh keys" is not the same than a "keyring".
BTW, the mentioned improvement should be released to candidate
next week.
I do have a keyring on my systems. But what does it have to do with charmcraft? Is this issue fixed on edge channel? When can we expect a new charmcraft release with this fix?
You do NOT have a keyring in the remote system. Charmcraft needs it to save the credentials in a safe manner. There is no issue to fix, this is the intended behaviour.
@heitorPB this can help you https://github.com/jaraco/keyring#using-keyring-on-headless-linux-systems
Closing, then. Thanks!
Am I missing something here?