[2.5beta1] juju switch allows switching to non-existent model

Bug #1800724 reported by Ryan Beisner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Anastasia
2.4
Fix Released
High
Anastasia

Bug Description

After destroying a model, the `juju switch` command unexpectedly succeeds in switching to the model which no longer exists. It is as if a model refresh is not happening ahead of the switch operation.

This condition was introduced some time between stable (2.4.4) and edge (2.5), and it is preventing OpenStack Charms CI from adopting Juju 2.5 in automation and test gates.

---

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ snap info juju
name: juju
summary: juju client
publisher: Canonical✓
contact: http://jujucharms.com
license: unset
description: |
  Through the use of charms, juju provides you with shareable, re-usable, and repeatable expressions
  of devops best practices.
commands:
  - juju
snap-id: e2CPHpB1fUxcKtCyJTsm5t3hN9axJ0yj
tracking: edge
refresh-date: today at 19:45 UTC
channels:
  stable: 2.4.4 (5426) 58MB classic
  candidate: 2.4.5+2.4-94045a7 (5611) 63MB classic
  beta: ↑
  edge: 2.5-beta1+develop-bb796b8 (5685) 67MB classic
  2.4/stable: 2.4.4 (5426) 58MB classic
  2.4/candidate: ↑
  2.4/beta: ↑
  2.4/edge: ↑
  2.3/stable: 2.3.9 (5267) 55MB classic
  2.3/candidate: ↑
  2.3/beta: ↑
  2.3/edge: 2.3.10+2.3-235656c (5618) 55MB classic
installed: 2.5-beta1+develop-bb796b8 (5685) 67MB classic

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju controllers
Use --refresh flag with this command to see the latest information.

Controller Model User Access Cloud/Region Models Machines HA Version
auto-osci-sv07* auto-osci-sv07 admin superuser serverstack/serverstack 3 1 none 2.5-beta1

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju models
Controller: auto-osci-sv07

Model Cloud/Region Status Machines Cores Access Last connection
auto-osci-sv07* serverstack/serverstack available 0 - admin never connected
controller serverstack/serverstack available 1 4 admin just now
default serverstack/serverstack available 0 - admin 4 hours ago

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju destroy-model auto-osci-sv07
WARNING! This command will destroy the "auto-osci-sv07" model.
This includes all machines, applications, data and other resources.

Continue [y/N]? y
Destroying model
Waiting on model to be removed...
Model destroyed.

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju models
Controller: auto-osci-sv07

Model Cloud/Region Status Machines Cores Access Last connection
controller serverstack/serverstack available 1 4 admin just now
default serverstack/serverstack available 0 - admin 4 hours ago

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju switch auto-osci-sv07:auto-osci-sv07
auto-osci-sv07:admin/auto-osci-sv07 (no change)

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju models
Controller: auto-osci-sv07

Model Cloud/Region Status Machines Cores Access Last connection
controller serverstack/serverstack available 1 4 admin just now
default serverstack/serverstack available 0 - admin 4 hours ago

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$

Tags: uosci
Ryan Beisner (1chb1n)
summary: - [2.5beta1] re-using model name is broken
+ [2.5beta1] juju switch allows switching to non-existent model
Changed in juju:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.5-beta1
assignee: nobody → Anastasia (anastasia-macmood)
Revision history for this message
Ryan Beisner (1chb1n) wrote :

Tried juju controllers --refresh to see if that would update things, but no. It still succeed in switching to a non-existent model:

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju models
Controller: auto-osci-sv07

Model Cloud/Region Status Machines Cores Access Last connection
controller serverstack/serverstack available 1 4 admin just now
default serverstack/serverstack available 0 - admin 5 hours ago

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju controllers --refresh
Controller Model User Access Cloud/Region Models Machines HA Version
auto-osci-sv07* auto-osci-sv07 admin superuser serverstack/serverstack 2 1 none 2.5-beta1

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju switch auto-osci-sv07:auto-osci-sv07
auto-osci-sv07:admin/auto-osci-sv07 (no change)

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ echo $?
0

Revision history for this message
Ryan Beisner (1chb1n) wrote :

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju models --all
Controller: auto-osci-sv07

Model Cloud/Region Status Machines Cores Access Last connection
controller serverstack/serverstack available 1 4 admin just now
default serverstack/serverstack available 0 - admin 5 hours ago

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju switch auto-osci-sv07:auto-osci-sv07
auto-osci-sv07:admin/auto-osci-sv07 (no change)
(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ echo $?
0

Revision history for this message
Anastasia (anastasia-macmood) wrote :

I know what has happenned here. This is related to a fix to ensure that we do not automatically delete a model from client cache if we know it no longer exists. This is only applicable to a model that has been current at some stage.

I'll work on the fix. Thank you for a reproducible scenario :)

Changed in juju:
status: Triaged → In Progress
Revision history for this message
Ryan Beisner (1chb1n) wrote :

Workaround:

juju show-model my-controller:my-model

This will still exit with an error if my-model doesn't exist.

Revision history for this message
Anastasia (anastasia-macmood) wrote :

I believe this to be the ONLY corner case that fell-out from the fix that stopped the surprising, automatic removal of 'current' models when they no longer exist.

What is happening here is that you have destroyed your current model but did not switch from it. In fact you have switched into it which is a no-op.. Even your reference in description has this extract:

(clients) jenkins@juju-001b34-osci-18:~/tools/0/charm-test-infra$ juju switch auto-osci-sv07:auto-osci-sv07
auto-osci-sv07:admin/auto-osci-sv07 *(no change)*

So your workaround here is valid but even switching to any other model and back again would have given you an error. Here is what I get: https://pastebin.ubuntu.com/p/RNsFMcpndk/

I will fix the check in switch commands that determines if the requested switch is no-op and will make it behave. Will propose shortly against 2.4 branch with the intention to forward-port to develop.

Revision history for this message
Anastasia (anastasia-macmood) wrote :
Revision history for this message
Anastasia (anastasia-macmood) wrote :
Changed in juju:
status: In Progress → Fix Committed
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.