Bug 1212725

Summary: beaker-client should show a useful error message when no config is found
Product: [Retired] Beaker Reporter: Karel Srot <ksrot>
Component: command lineAssignee: matt jia <mjia>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 19CC: aigao, asaha, dcallagh, dowang, mjia
Target Milestone: 20.2Keywords: Patch, Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-14 08:04:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 4 Dan Callaghan 2015-04-20 23:47:04 UTC
The beaker-client package does not ship with any config file (just an example one), the expectation is that the user will set up a config file pointing at their preferred Beaker instance. But if you install beaker-client and forget to set up a config it will fall back to connecting to https://localhost/hub/xmlrpc which is not useful.

Steps to reproduce:
1. Delete (or temporarily remove) /etc/beaker/client.conf and $HOME/.beaker_client/config
2. Install beaker-client
3. Run bkr whoami

Actual results:
XML-RPC connection to localhost failed: Connection refused, 5 retries left
XML-RPC connection to localhost failed: Connection refused, 4 retries left
XML-RPC connection to localhost failed: Connection refused, 3 retries left
XML-RPC connection to localhost failed: Connection refused, 2 retries left
XML-RPC connection to localhost failed: Connection refused, 1 retry left
Traceback (most recent call last):
  File "bkr/client/main.py", line 86, in <module>
    sys.exit(main())
  File "bkr/client/main.py", line 64, in main
    return cmd.run(*cmd_args, **cmd_opts.__dict__)
  File "bkr/client/commands/cmd_whoami.py", line 56, in run
    self.set_hub(**kwargs)
  File "bkr/client/__init__.py", line 71, in set_hub
    proxy_user=proxy_user)
  File "bkr/client/command.py", line 279, in set_hub
    self.hub = HubProxy(conf=self.conf, auto_login=auto_login)
  File "bkr/common/hub.py", line 68, in __init__
    self._login()
  File "bkr/common/hub.py", line 95, in _login
    if force or self._hub.auth.renew_session():
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1591, in __request
    verbose=self.__verbose
  File "bkr/common/xmlrpc.py", line 563, in request
    result = transport_class.request(self, *args, **kwargs)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "bkr/common/xmlrpc.py", line 437, in _single_request
    self.send_content(h, request_body)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1448, in send_content
    connection.endheaders(request_body)
  File "/usr/lib64/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/lib64/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.7/httplib.py", line 812, in send
    self.connect()
  File "/usr/lib64/python2.7/httplib.py", line 1204, in connect
    HTTPConnection.connect(self)
  File "/usr/lib64/python2.7/httplib.py", line 793, in connect
    self.timeout, self.source_address)
  File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

Expected results:
An error message indicating that no config file was found, and where to put one.

Comment 5 matt jia 2015-05-12 05:35:28 UTC
On Gerrit:

  http://gerrit.beaker-project.org/#/c/4209/

Comment 9 Amit Saha 2015-05-25 23:37:18 UTC
This seems regressive behavior to me. This prevents me from using "bkr" if I don't have a configuration file. 

So, if i just want to quickly do something, i am not allowed to do that.

Comment 10 Amit Saha 2015-05-25 23:43:28 UTC
I am going to reopen this bug to further discuss it. I think one way to go about this is that if I am specifying --hub, the configuration file is not checked. Otherwise, even if I am specifying --hub because I want to perform a one-off operation, I can't if I don't have a configuration file.

Comment 11 Amit Saha 2015-05-25 23:47:52 UTC
(In reply to Amit Saha from comment #10)
> I am going to reopen this bug to further discuss it. I think one way to go
> about this is that if I am specifying --hub, the configuration file is not
> checked. Otherwise, even if I am specifying --hub because I want to perform
> a one-off operation, I can't if I don't have a configuration file.

Even, bkr --help errors out.

Comment 12 matt jia 2015-05-25 23:52:17 UTC
(In reply to Amit Saha from comment #9)
> This seems regressive behavior to me. This prevents me from using "bkr" if I
> don't have a configuration file. 
> 
> So, if i just want to quickly do something, i am not allowed to do that.

I do not see this is a regressive behaviour as you just forgot to set up a configuration file. As what dan said in comment 4, beaker-client expects users to set up a config file.

Comment 13 Amit Saha 2015-05-27 03:58:47 UTC
(In reply to matt jia from comment #12)
> (In reply to Amit Saha from comment #9)
> > This seems regressive behavior to me. This prevents me from using "bkr" if I
> > don't have a configuration file. 
> > 
> > So, if i just want to quickly do something, i am not allowed to do that.
> 
> I do not see this is a regressive behaviour as you just forgot to set up a
> configuration file. As what dan said in comment 4, beaker-client expects
> users to set up a config file.

This is why I consider this regressive behavior:

Before this, I could use bkr CLI to do this without having a configuration file: (since I am a one-off user, for example)

bkr <sub-command> --hub=https://beaker.server.com

But now, I cannot. Asking the user to always have a configuration file even when the important piece of data, --hub is supplied is something I would not like.

Comment 14 matt jia 2015-05-27 04:09:42 UTC
(In reply to Amit Saha from comment #13)
> (In reply to matt jia from comment #12)
> > (In reply to Amit Saha from comment #9)
> > > This seems regressive behavior to me. This prevents me from using "bkr" if I
> > > don't have a configuration file. 
> > > 
> > > So, if i just want to quickly do something, i am not allowed to do that.
> > 
> > I do not see this is a regressive behaviour as you just forgot to set up a
> > configuration file. As what dan said in comment 4, beaker-client expects
> > users to set up a config file.
> 
> This is why I consider this regressive behavior:
> 
> Before this, I could use bkr CLI to do this without having a configuration
> file: (since I am a one-off user, for example)
> 
> bkr <sub-command> --hub=https://beaker.server.com
> 
> But now, I cannot. Asking the user to always have a configuration file even
> when the important piece of data, --hub is supplied is something I would not
> like.

Well, the thing is this behaviour is never ever officially supported by us.
And for you suggestion in comment 10, I do not think it will work in the current code structure.

Comment 15 Amit Saha 2015-05-28 05:11:53 UTC
(In reply to matt jia from comment #14)
> (In reply to Amit Saha from comment #13)
> > (In reply to matt jia from comment #12)
> > > (In reply to Amit Saha from comment #9)
> > > > This seems regressive behavior to me. This prevents me from using "bkr" if I
> > > > don't have a configuration file. 
> > > > 
> > > > So, if i just want to quickly do something, i am not allowed to do that.
> > > 
> > > I do not see this is a regressive behaviour as you just forgot to set up a
> > > configuration file. As what dan said in comment 4, beaker-client expects
> > > users to set up a config file.
> > 
> > This is why I consider this regressive behavior:
> > 
> > Before this, I could use bkr CLI to do this without having a configuration
> > file: (since I am a one-off user, for example)
> > 
> > bkr <sub-command> --hub=https://beaker.server.com
> > 
> > But now, I cannot. Asking the user to always have a configuration file even
> > when the important piece of data, --hub is supplied is something I would not
> > like.
> 
> Well, the thing is this behaviour is never ever officially supported by us.
> And for you suggestion in comment 10, I do not think it will work in the
> current code structure.

Trying to fix that: http://gerrit.beaker-project.org/#/c/4225/

Comment 16 Dan Callaghan 2015-06-09 01:20:26 UTC
I agree that bkr --help should always work, and bkr --hub should be enough to run without a config file (assuming that no auth is needed).

Comment 18 Amit Saha 2015-06-11 03:08:10 UTC
http://gerrit.beaker-project.org/#/c/4243/

Comment 24 Dan Callaghan 2015-07-14 08:04:40 UTC
Beaker 20.2 has been released.