juju-solutions / bundle-cwr-ci

Deploy the Juju Charm CI system
Other
2 stars 6 forks source link

Accessing test deployment #17

Open merlijn-sebrechts opened 7 years ago

merlijn-sebrechts commented 7 years ago

Test deployments are done under the ciuser. Is there a way to access those models? Maybe jobs should have an additional parameter that specifies which users the model should be shared with?

kwmonroe commented 7 years ago

Hey @galgalesh, I'm unclear what you mean by accessing the models that cwr creates. Generally speaking, I would prefer users not muck around with a model that's under test. However, I have wanted access to my models-under-test so I can monitor test progress. If this is what you're trying to do, I have a couple options for ya:

From a registered controller

List all models from a controller that is registered with the cwr charm. In this scenario, you can see my lxd controller has a controller and a workload model as well as a model owned by ci-70 (my ciuser) who has created a job-4-usable-corgi model:

$ juju switch
lxd:admin/default

$ juju models --all
Controller: lxd

Model                     Cloud/Region         Status     Machines  Cores  Access  Last connection
admin/controller          localhost/localhost  available         1      -  admin   just now
admin/default*            localhost/localhost  available         1      -  admin   23 hours ago
ci-70/job-4-usable-corgi  localhost/localhost  available         0      -  admin   never connected

At this point, you can get status, debug-log, or run commands on ci-70 units using the -m [<controller name>:]<model name> syntax available on most juju commands. For example:

$ juju status -m ci-70/job-4-usable-corgi
...
$ juju debug-log -m ci-70/job-4-usable-corgi
...
$ juju run -m ci-70/job-4-usable-corgi --unit namenode/0 'echo this is awesome!'
this is awesome!

The above works because the admin user on my lxd controller has access to all models created by other users. If you're not admin on your controller, i'm not sure how much interaction you could have with the ciuser models.

From the cwr/0 unit

If you are allowed to ssh into the cwr/0 unit, you can switch to the jenkins user and interact with the models like this:

$ juju ssh cwr/0
Last login: Fri Mar 10 23:34:13 2017 from 10.38.19.1
ubuntu@juju-95353e-0:~$ sudo su - jenkins
jenkins@juju-95353e-0:~$ juju models
Controller: lxd

Model                Cloud/Region         Status     Machines  Cores  Access  Last connection
job-4-usable-corgi*  localhost/localhost  available         6      -  admin   just now

If neither of these options help in your quest, let me know what you're trying to do.

merlijn-sebrechts commented 7 years ago

Thanks!

Two reasons why I want to access the models.

  1. Monitoring. (making sure that all models are properly cleaned etc..)
  2. Debugging a failed deployment. I like to use debug-hooks and ssh to the machines to check stuff etc.

Using the juju cli as jenkins user is good enough for 1.. What do you suggest for 2. ?

kwmonroe commented 7 years ago

@galgalesh I'm afraid I don't have a good answer for you. I see both juju ssh and juju debug-hooks give a permission denied or keys not found:

ubuntu@juju-b47b48-ci-shared-0:~$ juju debug-hooks -m ci-65-merlijn/job-2-hot-horse ubuntu/0
ERROR retrieving SSH host keys for "ubuntu-devenv/0": keys not found

ubuntu@juju-b47b48-ci-shared-0:~$ juju ssh -m ci-65-merlijn/job-2-hot-horse ubuntu/0
Permission denied (publickey).

Aside from installing debug-hooks onto the cwr unit and then running it as the jenkins user, I'm out of ideas. I need to bring in the big guns... paging @johnsca -- any thoughts?