Juju should be able to use a locally installed LXD image

Bug #1650651 reported by Bryan Quigley on 2016-12-16
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
juju
High
Andrew Wilkins

Bug Description

I should be able to manually import an image into LXD and have Juju use that.

= Setup (sudo lxd init previously done) =
wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-lxd.tar.xz https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-root.tar.xz
lxc image import xenial-server-cloudimg-amd64-lxd.tar.xz xenial-server-cloudimg-amd64-root.tar.xz --alias ubuntu-xenial

You should then be able to launch an image:
lxc launch ubuntu-xenial

= Go "Offline" =

Edit /etc/hosts and add:
127.0.0.1 cloud-images.ubuntu.com
127.0.0.1 streams.ubuntu.com

= Bug =
Then you try with juju bootstrap
$ juju bootstrap
Since Juju 2 is being run for the first time, downloading latest cloud information.
Fetching latest public cloud list...
Updated your list of public clouds with 1 cloud region added:

    added cloud region:
        - aws/us-east-2
Clouds
aws
aws-china
aws-gov
azure
azure-china
cloudsigma
google
joyent
localhost
rackspace

Select a cloud [localhost]:

Enter a name for the Controller [localhost-localhost]:

Creating Juju controller "localhost-localhost" on localhost/localhost
Looking for packaged Juju agent version 2.0.0 for amd64
To configure your system to better support LXD containers, please see: https://github.com/lxc/lxd/blob/master/doc/production-setup.md
Launching controller instance(s) on localhost/localhost...
ERROR failed to bootstrap model: cannot start bootstrap instance: image not imported!

Bryan Quigley (bryanquigley) wrote :

Actually this is also reproducible by doing a juju bootstrap, and then "going offline" even if it Juju downloaded the image files itself.

tags: added: lxd lxd-provider
Changed in juju:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.2.0
Curtis Hovey (sinzui) on 2017-03-24
Changed in juju:
milestone: 2.2-beta1 → 2.2-beta2
Andrew Wilkins (axwalk) wrote :

As of Juju 2.1, Juju will look for an local image with the alias "juju/$series/$arch", and use that if it exists; else it will fetch it from cloud-images and give it that alias.

So change your import command to:

    lxc image import xenial-server-cloudimg-amd64-lxd.tar.xz xenial-server-cloudimg-amd64-root.tar.xz --alias juju/xenial/amd64.

and you should be good.

Changed in juju:
assignee: nobody → Andrew Wilkins (axwalk)
status: Triaged → Fix Released
Changed in juju:
milestone: 2.2-beta2 → 2.1.0
feng xia (fengxia41103) wrote :

I created a local image as instructed above,
but deploying a charm to `trusty` series and watching `lxc image list`, it will still download `ubuntu-trusty` instead of using this local image.

Did I miss something?

------------------------------------------------------------------------------------
fengxia@local-charmdev:~/workspace/wss$ lxc image info trusty
Fingerprint: 203a6ae7d45cbe5c1411ad3f17b9b2429cb5ddfec69019fa96ce5710c4871504
Size: 365.92MB
Architecture: x86_64
Public: no
Timestamps:
    Uploaded: 2017/08/31 14:32 UTC
    Expires: never
    Last used: never
Properties:
    label: release
    os: ubuntu
    release: trusty
    serial: 20170811
    version: 14.04
    architecture: amd64
    description: ubuntu 14.04 LTS amd64 (release) (20170811)
Aliases:
    - gold-image (gold-image)
    - trusty (trusty)
    - juju/trusty/amd64 (juju/trusty/amd64)
Auto update: disabled

Andrew Wilkins (axwalk) wrote :

Feng, which version of Juju are you using?
What steps did you take, what did you expect to happen, and what happened?

feng xia (fengxia41103) wrote :

Version:

fengxia@local-charmdev:~/workspace/wss$ juju --version
2.0.2-xenial-amd64

Steps I took:

1. create a vanilla `trusty` LXD container named `gold`
2. ssh into `gold` container, `apt install python python-dev...`
3. in terminal, `$ lxc snapshot gold`, this created a snapshot, can be viewed from `$ lxc info gold`.
4. in terminal, `$ lxc publish gold/snap0 --alias gold-image` (according to https://insights.ubuntu.com/2016/04/01/lxd-2-0-image-management-512/). This create a new image `gold-image` based on container snapshot (created in #3).
5. `$ lxc image alias create juju/trusty/amd64`, based on recommendation on this thread. Verify using `$ lxc image info gold-image`. Similarly, I added alias `ubuntu-trusty`, `trusty`.
6. `$ lxc image delete ubuntu-trusty`. This is to delete the default ubuntu-trusty image downloaded by LXD.

So at this point, there should be one image (`$ lxc image list`) that has alias of `trusty` related name/alias.

Expect:

1. When `$ juju deploy [charm] --series trusty`, it will use `gold-image` as `trusty` image to create new machine.

What happened:

1. it will download `ubuntu-trusty` image (`$ lxc image list` will show this new image after a few minutes of downloading), then use this image to create a new machine.

Andrew Wilkins (axwalk) wrote :

Thanks for your response. Juju 2.1.0 or greater is required for this to work.

feng xia (fengxia41103) wrote :

Upgraded juju to version:

```
fengxia@local-charmdev:~$ juju --version
2.2.2-xenial-amd64
```

Issuing `juju deploy` command, under the `Message`, it says `copying image for ubuntu-trusty from https://cloud-images.ubuntu.com/release/: rootfs: 79%`.

Below is my local LXD image:

```
fengxia@local-charmdev:~$ lxc image info juju/trusty/amd64
Fingerprint: 203a6ae7d45cbe5c1411ad3f17b9b2429cb5ddfec69019fa96ce5710c4871504
Size: 365.92MB
Architecture: x86_64
Public: no
Timestamps:
    Uploaded: 2017/08/31 14:32 UTC
    Expires: never
    Last used: never
Properties:
    version: 14.04
    architecture: amd64
    description: ubuntu 14.04 LTS amd64 (release) (20170811)
    label: release
    os: ubuntu
    release: trusty
    serial: 20170811
Aliases:
    - juju/trusty/amd64 (juju/trusty/amd64)
Auto update: disabled
```

Any pointer?

Andrew Wilkins (axwalk) wrote :

Did you update just the client, or did you also rebootstrap/upgrade the controller? The controller is the main thing that needs to be 2.1+.

feng xia (fengxia41103) wrote :

Verified.

1. Update juju to 2.2.2
2. re-bootstrap a controller

It is now using a local image w/ alias `juju/trusty/amd64`.

Thank you Juju.

alam (alam004) wrote :

Hi,

Is it possible to bootstrap in offline mode using juju version 2.5.7? Or this procedure is not supporting? @Andrew Wilkins (axwalk)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers