"local" charm schema should allow deploying previously deployed local charms

Bug #1611514 reported by Katherine Cox-Buday
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
Critical
Katherine Cox-Buday

Bug Description

As part of the work to make deploying local charms easier, we removed the "local:" schema in favor of relative-path notation (e.g. juju deploy ./foo) and declaring the supported series in metadata.yaml.

However, we still store local charms in Juju's database using the "local:" notation.

We should re-enable utilizing the "local:" schema when deploying charms, but change the meaning to be "deploy this charm which should already exist in the controller".

Tags: feature
Changed in juju-core:
status: New → In Progress
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

Will this change allow me to upload a charm to a model and then deploy it via the api using a 'local:' charm-url?

Changed in juju-core:
milestone: none → 2.0-beta16
importance: Undecided → High
Revision history for this message
Richard Harding (rharding) wrote :

@tim yes the plan is that this will enable exactly that.

affects: juju-core → juju
Changed in juju:
milestone: 2.0-beta16 → none
milestone: none → 2.0-beta16
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

Here's a python script to repro. You'll need the latest lp:python-jujuclient, which you can install from source or from ppa:tvansteenburgh/ppa.

tvansteenburgh@xenial-vm:~/python-jujuclient⟫ cat deploy_test.py
#!/usr/bin/env python3

import logging
import ssl

from jujuclient.juju2.environment import Environment

log = logging.getLogger(__name__)

# Constants, change these for your environment
API_SERVER = '10.0.4.52'
USER = 'user-admin'
PASSWORD = 'd7247825e7df512140005cb2b6aab925'
CHARM_DIR = '/home/tvansteenburgh/src/charms/trusty/ubuntu'

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    # Login to controller
    endpoint = 'wss://%s:17070' % (API_SERVER)
    controller = Environment(endpoint)
    controller.login(PASSWORD, user=USER)

    # Login to default model
    models = controller.models.list()
    for m in models['user-models']:
        if m['model']['name'] == 'default':
            model_endpoint = '{}/model/{}/api'.format(
                endpoint, m['model']['uuid'])
            model = Environment(model_endpoint)
            model.login(PASSWORD, user=USER)

    # Workaround for certificatge failure (hack)
    ssl._create_default_https_context = ssl._create_unverified_context

    # Upload a local charm to the model
    res = model.add_local_charm_dir(CHARM_DIR, "trusty")
    log.debug("Added local charm: %s", res)

    # Turn on rpc debugging so we can see raw api calls
    model._debug = True

    # Deploy the uploaded charm
    res = model.deploy('mycharm', res['charm-url'])
    log.debug("Deploy response: %s", res)

And here's the output of running it. As you can see, the local charm is uploaded successfully and we get a charm-url back, but then when we try to deploy the charm using that url, it doesn't work:

tvansteenburgh@xenial-vm:~/python-jujuclient⟫ .tox/py27/bin/python deploy_test.py
DEBUG:__main__:Added local charm: {u'charm-url': u'local:trusty/ubuntu-3'}
DEBUG:jujuclient.rpc:rpc request:
{
  "params": {
    "applications": [
      {
        "placement": [],
        "num-units": 1,
        "application": "mycharm",
        "charm-url": "local:trusty/ubuntu-3",
        "config": {},
        "constraints": {}
      }
    ]
  },
  "request-id": 2,
  "version": 1,
  "request": "Deploy",
  "type": "Application"
}
DEBUG:jujuclient.rpc:rpc response:
{
  "request-id": 2,
  "response": {
    "results": [
      {
        "error": {
          "message": "charm \"local:trusty/ubuntu-3\" not found",
          "code": "not found"
        }
      }
    ]
  }
}
DEBUG:__main__:Deploy response: {u'results': [{u'error': {u'message': u'charm "local:trusty/ubuntu-3" not found', u'code': u'not found'}}]}

Revision history for this message
Katherine Cox-Buday (cox-katherine-e) wrote :

@timvansteenburgh: I think you're tracking the wrong bug. Your issue looks to do with deploying a local charm from the filesystem. This bug is to deploy pre-deployed local charms from the controller, e.g.: `juju deploy local:xenial/foo-0 bar`

To everyone else:

I have this working, but it looks like there are some oddities both with placement and removing applications. E.g.

1. If I `juju deploy local:xenial/foo-0 bar`, the application is added, but no machine/container is provisioned
2. If I `juju remove-application bar`, I get an error "ERROR charm "local:xenial/bar" not found (not found)", but the application is removed successfully.
3. If I remove all the applications referencing this charm, I can still redeploy the charm from the controller (i.e. it's not being cleaned up). This is likely being addressed by another round of bug fixes, but is worth noting.

I need to investigate these to determine whether it's worth landing this with outstanding bugs. Because of that, this may not make b16. I'll post the decision in ~3h.

Revision history for this message
Katherine Cox-Buday (cox-katherine-e) wrote :

PR here: https://github.com/juju/juju/pull/6087

I think I've solved all the issues.

tags: added: blocker
Changed in juju:
importance: High → Critical
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.0-beta16 → 2.0-beta17
Changed in juju:
status: In Progress → Fix Committed
tags: removed: blocker
Curtis Hovey (sinzui)
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.