Duplicated prefix in the url used by the CLI

Bug #1075597 reported by Diogo Matsubara on 2012-11-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Critical
Jeroen T. Vermeulen
1.2
Critical
Jeroen T. Vermeulen

Bug Description

I logged in using maas-cli but when I use any command (e.g. maas-cli maas nodes list) I get a 302 error

ubuntu@autopkgtest:~$ maas-cli maas nodes list
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en-us" />
    <link rel="shortcut icon" href="/MAAS/static/img/favicon.ico"/>
    <link rel="stylesheet" href="/MAAS/combo/maas/?css/base.css&css/typography.css&css/forms.css&css/layout.css&css/modifiers.css&css/components/flash_messages.css&css/components/pagination.css&css/components/table_list.css&css/components/title_form.css&css/components/blocks.css&css/components/yui_panel.css&css/components/yui_overlay.css&css/components/yui_node_add.css&css/components/data_list.css&css/components/search_box.css&css/ubuntu-webfonts.css" />
    <title>Login | autopkgtest MAAS
</title>
    <script type="text/javascript">
<!--
var YUI_config = {
    debug: false,
    combine: true,
    filter: 'min',
    root: '',
    base: '/MAAS/combo/yui/?',
    comboBase: '/MAAS/combo/yui/?',
};
var MAAS_config = {
    uris: {
        login: '/MAAS/accounts/login/',
        statics: '/MAAS/static/',
        maas_handler: '/MAAS/api/1.0/maas/',
        nodes_handler: '/MAAS/api/1.0/nodes/',
        account_handler: '/MAAS/api/1.0/account/'
        },
    debug: false
};
// -->
</script>
<script type="text/javascript"
    src="/MAAS/combo/yui/?yui-base/yui-base-min.js">
</script>
<script type="text/javascript"
    src="/MAAS/combo/maas/?js/morph.js&js/user_panel.js&js/node_add.js&js/node.js&js/prefs.js&js/utils.js&js/node_views.js&js/longpoll.js&js/enums.js&js/power_parameters.js&js/nodes_chart.js">
</script>

    <script type="text/javascript">
    <!--
    YUI().use('node', function (Y) {
      Y.on('load', function() {
        Y.one('input[type=text]').focus();
      });
    });
    // -->
    </script>

</head>
<body class="modal-content login ">

  <div class="center-page-wrapper">
    <div class="center-page-content">

      <div id="body">
        <ul id="flash-messages">

        </ul>

          <h1 id="page-title">Metal as a Service</h1>

        <div id="content">
            <div id="sidebar"></div>

  <h2>Login to autopkgtest MAAS
</h2>

  <form method="post" action="/MAAS/accounts/login/"><div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='4wyki7qiioi5EbGNG1FEdTsQNJ6l0nVN' /></div>
    <input type="hidden" name="next" value="/MAAS/MAAS/api/1.0/nodes/" />
    <ul>

<li class="username">
  <label for="id_username">

    Username

      <span class="required">(required)</span>

  </label>

    <input id="id_username" type="text" name="username" maxlength="30" />

  <span class="help"></span>

</li>

<li class="password">
  <label for="id_password">

    Password

      <span class="required">(required)</span>

  </label>

    <input type="password" name="password" id="id_password" />

  <span class="help"></span>

</li>

      <li class="form-submit"><input type="submit" value="Login" /></li>
    </ul>
  </form>

            <div class="clear"></div>
        </div>
      </div>
      <div id="footer">
        <img src="/MAAS/static/img/ubuntu_logo_footer.png" alt="Ubuntu" />

        <div class="clear"></div>
      </div>
    </div>
  </div>
</body>
</html>

ubuntu@autopkgtest:~$

Apache log shows this for the request:
10.98.0.90 - - [06/Nov/2012:15:29:51 +0000] "GET /MAAS/MAAS/api/1.0/nodegroups/master/interfaces/?op=list HTTP/1.1" 302 345 "-" "Python-httplib2/0.7.4 (gzip)"

Note the /MAAS/MAAS in the request. Somewhere that's been added to the request.

ubuntu@autopkgtest:~$ maas-cli list
maas http://10.98.0.90/MAAS/api/1.0/ G2UxYyWkcT6R6jLkQQ:eBptexySymtgxH7VgF:XdraqcBzpMUramU6GGGFyYQydHTUehwz

Shows I'm logged in successfully.

Tags: cli Edit Tag help

Related branches

Raphaël Badin (rvb) on 2012-11-06
Changed in maas:
importance: Undecided → Critical
status: New → Triaged
tags: added: api maas-cli
Raphaël Badin (rvb) wrote :

I managed to recreate the problem (using the package in the daily ppa):

maas-cli login maas http://127.0.0.1/MAAS/api/1.0/ creds:creds:creds
maas-cli maas node-groups list => returns the HTLM content of the login page

From apache's access log:
127.0.0.1 - - [06/Nov/2012:15:33:31 +0000] "GET /MAAS/api/1.0/describe/ HTTP/1.1" 200 6050 "-" "Python-httplib2/0.7.4 (gzip)"
127.0.0.1 - - [06/Nov/2012:15:33:42 +0000] "GET /MAAS/MAAS/api/1.0/nodegroups/?op=list HTTP/1.1" 302 322 "-" "Python-httplib2/0.7.4 (gzip)"

The problem is the URL used to fetch the list of the nodegroups; it contains a duplicated prefix: '/MAAS/MAAS/'.
Here is the content of /MAAS/api/1.0/describe/: http://paste.ubuntu.com/1337566/
The 'path' field of the handlers seems fine but the 'uri' field contains '/MAAS/MAAS'.

This seems to be a very recent problem and the last change I can think of in this area is https://code.launchpad.net/~allenap/maas/api-uri-bug-1059645/+merge/132527. Probably worth a look.

summary: - maas-cli commands not working. Returns a http 302 error
+ Duplicated prefix in the url used by the CLI
tags: added: cli
removed: api maas-cli
Changed in maas:
status: Triaged → In Progress
assignee: nobody → Jeroen T. Vermeulen (jtv)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related blueprints